Question

i'm newbie to both cocos2d and box2d and i've been struggling for two days with this problem : i have a scene with many sprites dropping down (with bodies attached to them). and i have a BackgroundLayer from which i add my background image into the scene (which is not involded into the physics simulation). In my backgroundLayer i'm trying to perform an action on a sprite : (it blink in the first position and jump directly to the end position )

id flyBubble = [CCEaseInOut actionWithAction:[CCMoveTo actionWithDuration:0.7 position:randomEndPosition]];

but my sprite doesn't respond at all to this action!! my sprite doesn't have any b2body attached and seems like it respond to the tick: method of the physics world (which is in my Main Scene). How can i perform an action to a sprite that doesn't have a b2body attached. any help would be appreciated!!! thanks

here is the entire code :

    CCSprite *bubble = [CCSprite spriteWithFile:@"bubble.png"];
[self addChild:bubble];
CGPoint startPosition = ccp(100, 100);
bubble.position = startPosition;    
CGPoint endPosition = ccp(400, 400);

id flyBubble = [CCEaseInOut actionWithAction:[CCMoveTo actionWithDuration:0.7 position:randomEndPosition]];
id remove = [CCCallBlockN actionWithBlock:^(CCNode *node) {        
    [self removeFruit:(CCSprite *)node];        
}];

[bubble runAction:[CCSequence actions:flyBubble, remove, nil]];
Was it helpful?

Solution 2

i did a little mistake that costs me lot of times. it was in this line of code

id flyBubble = [CCEaseInOut actionWithAction:[CCMoveTo actionWithDuration:0.7 position:randomEndPosition]];

CCEaseInOut doesn't work i don't know why!! when i used CCEaseExponentialInOut it worked perfectly.

Thanks anyway!

OTHER TIPS

I guess source and destination position of sprite is same. So no difference in action.

try like this..

sprite.position = ccp(0,0);

id flyBubble = [CCMoveTo actionWithDuration:0.7 position:randomEndPosition];

[sprite runAction:flyBubble];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top