i have this game like doodlejump
i inserted some monsters and bullets on the player
the player fires a bullet and deletes the target
i inserted a nslog to both so i know if the bullet fires and the target shows
all is working smooth in the simulator ios 4.0
but when everytime i install it on the device
the bullet and the target seems to be not appearing(yes only those two the game is still running smooth)
but everytime i check the console i can see the nslog of the bullet and target
i tried it on 3 different phones ios 4.0, 5.0 and 4.2
now im confused if what seems to be the problem
i checked for same issues at google but i cant seem to find one
i also checked for spellings and mini problems but still it is occurring.
What seems to be causing this issue?
PS:the app im working on is outdated,it is old version of COCOS2d. does this
affect it? i tried on upgrading but i have so many errors that i dont
know thats why i go back to the default.
The Monsters are appearing for about .5 sec then will disappear suddenly is this because of the spriteMoveFinished?
here are the codes(target):
-(void)addTarget {
Sprite *target =[Sprite spriteWithFile:@"him.png"];
CGSize winSize = [[Director sharedDirector]winSize];
int minX = winSize.width/6;
int maxX = winSize.width - target.contentSize.width/2;
int rangeX = maxX - minX;
int actualX = (arc4random() % rangeX) + minX;
target.position = ccp(actualX,500);
NSLog(@"Location:%f",target.position);
[self addChild:target];
int minDuration = 2.0; int maxDuration = 4.0;
int rangeDuration = maxDuration - minDuration;
int actualDuration = (arc4random() % rangeDuration)+minDuration;
id actionMove = [MoveTo actionWithDuration:actualDuration position:ccp(actualX, -target.contentSize.height/2)];
id actionMoveDone = [CallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)];
[target runAction:[Sequence actions:actionMove,actionMoveDone, nil]];
target.tag = 1;
[_targets addObject:target];
}
(bullets):
-(void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
AtlasSpriteManager *spriteManager = (AtlasSpriteManager*)[self getChildByTag:kSpriteManager];
AtlasSprite *bird = (AtlasSprite*)[spriteManager getChildByTag:kBird];
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:[touch view]];
location = [[Director sharedDirector]convertCoordinate:location];
Sprite *projectile = [Sprite spriteWithFile:@"psn.png"];
projectile.position = ccp(bird.position.x,bird.position.y);
CGSize winSize = [[Director sharedDirector]winSize];
int offX = location.x - projectile.position.x;
int offY = location.y - projectile.position.y;
[self addChild:projectile];
float scalarX = 1.0f;
if(offX < 0.0f) scalarX = -1.0f;
int realX = scalarX * (winSize.width + (projectile.contentSize.width/2));
float ratio = (float) offY / (float) offX;
int realY = (realX *ratio) +projectile.position.y;
CGPoint realDest = ccp(realX,realY);
int offRealX = realX - projectile.position.x;
int offRealY = realY - projectile.position.y;
float length = sqrtf((offRealX*offRealX)+(offRealY*offRealY));
float velocity = 480/1;
float realMoveDuration = length/velocity;
[projectile runAction:[Sequence actions:[MoveTo actionWithDuration:realMoveDuration position:realDest],
[CallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)], nil]];
NSLog(@"Shoot!");
projectile.tag = 2;
[_projectiles addObject:projectile];
}
Thanks i hope this will be resolved…
Odd. Things to try quickly would be:
Delete the app from the device itself (hold on the app icon until the ‘x’ appears and delete it) then do a clean build. This will force all assets to be replaced on the phone.
Do you have retina support enabled? If so, is there a file in your resources called ‘him-hd.png’ that is corrupt? It would try to load that one first if a retina device is detected.
Does it fail on the simulator for a retina device? You can change the device being simulated in the iOSSimulator menu bar.
When you added the images to the project, did you select ‘Copy items into destination group’s folder (if needed)? This is important as otherwise the images won’t be included with the bundle
Finally, did you check the Target Membership for the images so it is set to the app target? You can check this by selecting the image in xCode and looking at the File Inspector->Target Membership. There should be a check next to your application.