精灵动画表
我正在使用 cocos2d 和 box2d phisycs 开发一个应用程序。我想让我的精灵在移动时有动画效果。我在 Zwoptex 中制作了 *.plist 和 *.png 文件,并将它们添加到我的项目中。现在,我正在尝试创建一个精灵:
[[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@"SquirrelAnimation.plist"];
node = [CCSpriteBatchNode batchNodeWithFile:@"SquirrelAnimation.png" capacity:100];
spriteTexture = [node texture];
b2BodyDef bodyDef;
bodyDef.type = bodyType;
CGSize size = [CCDirector sharedDirector].winSize;
CGPoint point = ccp(size.width / 2, size.height / 2);
bodyDef.position.Set(point.x / PTM_RATIO, point.y / PTM_RATIO);
body = world->CreateBody(&bodyDef);
sprite = [PhysicsSprite spriteWithTexture:spriteTexture];
[sprite setPhysicsBody:body];
[node addChild:sprite];
但是此代码创建一个精灵,其中所有帧都为节点。我做错了什么?
I'm developing an app using cocos2d and box2d phisycs. I whant to make my sprite animate on moving. I made a *.plist and *.png files in Zwoptex, and added them to my project. Now, I'm trying to create a sprite:
[[CCSpriteFrameCache sharedSpriteFrameCache]addSpriteFramesWithFile:@"SquirrelAnimation.plist"];
node = [CCSpriteBatchNode batchNodeWithFile:@"SquirrelAnimation.png" capacity:100];
spriteTexture = [node texture];
b2BodyDef bodyDef;
bodyDef.type = bodyType;
CGSize size = [CCDirector sharedDirector].winSize;
CGPoint point = ccp(size.width / 2, size.height / 2);
bodyDef.position.Set(point.x / PTM_RATIO, point.y / PTM_RATIO);
body = world->CreateBody(&bodyDef);
sprite = [PhysicsSprite spriteWithTexture:spriteTexture];
[sprite setPhysicsBody:body];
[node addChild:sprite];
but this code makes one sprite with all frames to node. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样提取帧...
Extract frame like this...