Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17093

Animation using SpriteFrameCache affects physics body?

$
0
0

@kula888 wrote:

I tried to load a spritesheet.png file using a plist file for animation. My problem is using SpriteFrameCache affects physics body. I expected the physics body would not move during animation, but the animation seems putting some force to the physics body that I attached to mSprite. It doesn't make sense to me. So I tried to do it with individual png file using SpriteFrame and it works fine. Anyone has idea why SpriteFrameCache affects physics body? Your help would be appreciated. smile

//Animations using SpriteFrameCache (affects physics body)
Vector<SpriteFrame*> frames;
Size playerSize = mSprite->getContentSize();
auto frame1 = Sprite::createWithSpriteFrameName("fly1.png");
auto frame2 = Sprite::createWithSpriteFrameName("fly2.png");
frames.pushBack(SpriteFrameCache::getInstance()->spriteFrameByName("fly1.png"));
frames.pushBack(SpriteFrameCache::getInstance()->spriteFrameByName("fly2.png"));
auto animation = Animation::createWithSpriteFrames(frames, 0.2f);
mSprite->runAction(CCAnimate::create(animation));

//Animations using SpriteFrame only (work as expected)
Vector<SpriteFrame*> frames;
Size playerSize = mSprite->getContentSize();
frames.pushBack(SpriteFrame::create("fly2.png", Rect(0, 0, playerSize.width, playerSize.height)));
frames.pushBack(SpriteFrame::create("fly1.png", Rect(0, 0, playerSize.width, playerSize.height)));
auto animation = Animation::createWithSpriteFrames(frames, 0.2f);
mSprite->runAction(CCAnimate::create(animation));

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 17093

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>