ios - CCScaleTo causes CCSprite to move, apart from scaling it -


i pretty new cocos2d , trying implement scaling sprite , down. using cceaseinout perform task. code snippet looks follows:

barrel setanchorpoint:ccp(0.5,0.5)]; id scaleupaction =  [cceaseinout actionwithaction:[ccscaleto actionwithduration:.35 scalex:1.5 scaley:1.5] rate:1.0]; id scaledownaction = [cceaseinout actionwithaction:[ccscaleto actionwithduration:.35 scalex:1.0 scaley:1.0] rate:1.0]; ccsequence *scaleseq = [ccsequence actions:scaleupaction, scaledownaction, nil]; [barrel runaction:scaleseq]; 

barrel of type ccnode.

i have tried set anchorpoint (0.5,0.5) considering scaling might happening around centre. but, doesn't seem help.

i have seen similar question: ccsprite moved when using ccscaleto or ccscaleby. unfortunately, there no answer in link solves problem.

it great if point me in right direction.

note: might useful mention barrel object being used box2d object. problem arising there? cheers!

note: have following in code:

nsobject* bodyuserdataa = (__bridge nsobject*)contact->getfixturea()->getbody()->getuserdata(); if ([bodyuserdataa iskindofclass:[odppbarrel class]]) { barrel = (odppbarrel *)bodyuserdataa; }

always try not change anchorpoints of node unless must requirement. default anchorpoint nodes set 0.5 only.

id scaleupaction =  [ccscaleto actionwithduration:.35 scale:1.5]; id scaledownaction = [ccscaleto actionwithduration:.35 scale:1.0]; ccsequence *scaleseq = [ccsequence actions:scaleupaction, scaledownaction, nil]; 

now if barrel of type ccsprite , used in b2body's userdata field then: body (e.g. mybody) box2d world.

ccsprite *tmpsprite = (ccsprite *)mybody->getuserdata; if(tmpsprite)   [tmpsprite runaction:scaleseq]; 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -