cocos2d/box2d 的麻烦
我刚刚开始使用 cocos2d 和 box2d for iOS SDK,并且遇到了一些问题。我让模板正常工作,并编译了测试应用程序(单击屏幕并出现一个带有随机字母的框的应用程序)。
我的第一个问题是我不知道如何获得空白模板。当我开始新的应用程序时,有没有快速的方法可以做到这一点?
我的第二个问题是我不知道如何简单地改变对象的颜色。我可以这样定义:
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(p.x/PTM_RATIO, p.y/PTM_RATIO);
b2Body *body = world->CreateBody(&bodyDef);
b2CircleShape circle;
circle.m_radius = .5f;//These are mid points for our 1m box
b2FixtureDef fixtureDef;
fixtureDef.shape = &circle;
fixtureDef.density = 1.0f;
fixtureDef.friction = 0.1f;
fixtureDef.restitution = 0.3f;
body->CreateFixture(&fixtureDef);
但是有没有一种简单的方法可以使某些东西具有某种颜色?
最后一个问题:这个示例应用程序是否启用了加速度计重力?
谢谢!
I have just started working with cocos2d and box2d for iOS SDK, and have a few problems. I got the templates working, and got the test app (the one where you click the screen and a box with a random letter appears) to compile.
My first problem is that I can't figure out how to get a blank template. Is there a quick way to do this when I begin a new app?
My second problem is that I can't figure out how to just simply change the color of an object. I can define something like this:
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position.Set(p.x/PTM_RATIO, p.y/PTM_RATIO);
b2Body *body = world->CreateBody(&bodyDef);
b2CircleShape circle;
circle.m_radius = .5f;//These are mid points for our 1m box
b2FixtureDef fixtureDef;
fixtureDef.shape = &circle;
fixtureDef.density = 1.0f;
fixtureDef.friction = 0.1f;
fixtureDef.restitution = 0.3f;
body->CreateFixture(&fixtureDef);
But is there a simple way to make something a certain color?
Final question: does this sample app have the accelerometer-gravity enabled?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了使某个主体具有特定的颜色,请将“userData”分配给该主体。 userData 是您的精灵,具有您想要的特定颜色
并且回复您的最终答案是“是”。
For making a certain body a specific color, assign 'userData' to the body. userData is your sprite with specific color you wanted
And reply to your final answer is YES.
要制作空白模板,请执行以下操作
删除以下行 尝试一下。 :)
For making blank template do the following
Try it out. :)