Sorry if this is answered somewhere else, but I couldn't find it.
It's pretty simple, I want to set the Z-order of the sprites I create in Objective-C, specifically in Cocos2D.
This is the error I get when trying to build the following code:
CCSprite *mySprite = [CCSprite spriteWithFile:@"mySpriteImage.png" rect:CGRectMake(...
I'm converting the game I'm working on from UIkit to coocos2d. Using UIKIT I would use the code below code to pass the touch evens to a method. What would be the equivalent in Cocos2d?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// Save the position
for (UITouch *touch in touches) {
// Send to th...
Friends i am new to cocos2d programming and Mac in general!
I have noticed this EXC_BAD_ACCESS errors ruining most of my time... Take the following snippet of code from the Geek & Dad's tutorial...
-(void) AddEnemyAtX:(int)x Y:(int)y {
CCSprite *enemy1 = [CCSprite spriteWithFile:@"enemy1.png"];
enemy1.position = ccp(x,y);
...
I am writing a game in which there are thumbnails of mini games displayed in a grid, CCSprites in a NSArray. One of these is then scaled and moved to create a zooming effect. Once it has zoomed in it is hidden to reveal the actual "live" minigame (a CCNode), which has been added to the scene invisibly while the zooming animation took pla...
1- is it possible to use interface builder to design the game background and then use code to add cocos2d objects?
2- Is it possible to use iphone UI objects as well as cocos2d objects, for example uibutton, uiScrollView, etc.
3- is it possible to useiphone default template, and cocos2d templates togather? for example my home screen is...
I am trying to track down a memory leak in my cocos2D game. I have run the game using instruments to find what is causing the leaks and the bulk of the problem seems to come from this method.
-(void)setColour:(int)c {
switch (c) {
case RED:
images[SMALL_BUBBLE_IMAGE] = [[CCTexture2D alloc] initWithImage:[UIImage imageNamed...
I have an 8 by 8 matrix of sprites that I need to be able to rotate all of them 90 degrees at once. The way I've done it is using nested for loops, and a 2 dimensional array of sprite pointers.
for(row = 0;row<9;row++){
for(column = 0;column<8;column++){
[trolls[row][column] runAction:[RotateBy actionWithDuration:0.01 an...
after I create a button, the button rect which can touch is not the same with the ccsprite rect. I can just touch some part of the button. when I click the other part, the isEnabled_ is NO, this is weird, because I really click the button. and I also check the ccsprite rect, it's right.
...
Hey all
Im working on an app for the iphone and i am new to cocos2d and objective c.
Im having some trouble getting a sprite animation to be position as i want it. I have a background sprite and have a second animation sprite that goes over it. In this case the background is a person and the animation sprite is the eyes blinking.
CGSiz...
I am having trouble finding a tutorial on CCCamera. And have even heard from others there is no CCCamera tutorial. But, to the point, the thing that I really want to know is simply: How do I move the coordinates of the cammera? I tried this after looking at the reference:
CCCamera *myCam = [[CCCamera alloc] init];
[myCam setCenterX:...
Hello,
I've been fighting this for a few hours now and I'm getting fed up. My project builds fine with a debug simulator build , release simulator build and a debug device build, but for some reason it won't build with a release device build. I have a static library containing my cocos2d code, and another static library containing a g...
hi, i've a huge problem..
I want to use both cocos2d and UIkit frameworks in one application, here is the scenario:
user log in, via UIkit, then play a game written in cocos2d, and after that the actual uikit ordinary application starts. the problem is that, after starting cocos game, i'm unable to return to uikit view-based application....
I copied the code from the ParticleDemo implementation into my project and tried to make it work. I want that when I click an image it should change/replace the scene. For some reason the scene is not getting replaced. Here is my implementation:
//
// HelloWorldLayer.h
// FirstCocoaApplication
//
// Created by Mohammad Azam on 8/27/1...
Hi all
Im making an app for the iphone using cocos2d and i am trying to figure out the best approach for removing items from a NSmutableArray and from the layer at the same time.
What i mean by this is that the objects within the array inherit from ccNode and contain a ccsprite which i have added as a child to the cclayer. The below cod...
i'm developing a physics game with cocos2d framework. I added iAd to it. When the ad appears, the scenary elements get disoriented (sprites jump). i've notice FPS decrease a lot and i don't know what to do to solve the problem. Any ideas?
...
Hello everyone,
I try to create my own tile map dynamically such as some buildings created with the help of database. I try to use CCSprite on object layers. However, when i scroll the map, also CCSprites' move too. I don't want to move all of the Sprites whenever player scrolls the map. (For performance issues)
Then, I decided to creat...
I'm using cocos2d for the iPhone to create an infinitely scrolling horizontal tile map. To achieve this, I've generated a library of 'segments', which are basically horizontal chunks of levels that I randomly choose from and append to the end of that particular levels tile map. When tiles scroll off of the left of the screen they are rem...
I can initialize or create a new CCSprite object using the following code:
NSString *fileName = [[imagesPath objectAtIndex:i] lastPathComponent];
CCSprite *sprite = [CCSprite spriteWithFile:fileName];
Now, is there anyway to later find out the name of the image file used for the particular CCSprite object?
UPDATE 1:
userD...
Hello,
I try to show an intro and replaceScene when the intro has finished. But, when the movie finish, app is crashing on [[CCDirector sharedDirector] replaceScene:[CCFadeTransition transitionWithDuration:0.5f scene:[MenuScene scene]]];.
code is;
- (void) moviePlayBackDidFinish {
[self.moviePlayer stop];
[[CCDirector sharedDirecto...
Hi, I've created Cocos Apps, then inserted sprite in that. I moved sprite to mouse moved location.sprite's coordinates are out of the screen borders.
any one explain how can I convert sprite coordinates to screen coordinates?
That would be in (320 * 480) format!!!
...