-
abhishekLikes 0Problem Description
i want to play a sequence of animations on a sprite.
and once the actions are done, i want to call a function.
here is the sample code i have written as of now:auto move1 = MoveBy::create(0.05, Point(card1->getBoundingBox().size.width*0.05, 0));
auto move2 = MoveBy::create(0.05, Point(-card1->getBoundingBox().size.width*0.05, 0));
auto action = Sequence::create(move1, move2, move2, move1, NULL);
card1->runAction(action);
so once the sequence is complete, i want to call a function say fn_check
how can i do this?
any help will be very much appreciated
:)
-
Sonar Systems adminLikes 0
Go to our Cocos API Guide – http://cocos.sonarlearning.co.uk/v1.0/docs/actions
Go to the bottom, you need to use Call Func and Sequences, let us know if you need any more help :D
-
abhishekLikes 0
hi,
i checked the link and the section you told me about.
so this is the code you are referring to:CallFunc *functionAction = CallFunc::create( functionToCall ); nodeName->runAction( functionAction ); but i still dont know how to use this code in my current piece of code. this is my code: auto move1 = MoveBy::create(0.05, Point(card1->getBoundingBox().size.width*0.05, 0)); auto move2 = MoveBy::create(0.05, Point(-card1->getBoundingBox().size.width*0.05, 0)); auto action = Sequence::create(move1, move2, move2, move1, NULL); card1->runAction(action); so according to your code syntax above, where do i include functionAction?
-
abhishekLikes 0
another question if you dont mind..
i used this line of code in cocos2d-x v2.2 to dynamically change image of a sprite, the image was saved in sprite sheet:
sp_baby1->setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(ccsf("baby4_happy_%d.png",baby1)));
but now i am using cocos2d-x v3.0 and this line does not work anymore.
i want to be able to change the image of a sprite dynamically. and the images are in a sprite sheet.
for example: baby_1 to baby_10
now depending upon the value of myInt (could be between 1 to 10), i want to set the image of my sprite.
how can i do this?
could you please help?
thanksThis reply has been verified.
-
Sonar Systems adminLikes 0This reply has been verified.
Login to reply