public: @H_403_6@... virtual void update(float dt); @H_403_6@... private: float ry; cocos2d::Sprite * s;
- 然后将init函数的实现改为:
// on "init" you need to initialize your instance
@H_403_6@bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
@H_403_6@if ( !Layer::init() )
{
@H_403_6@return @H_403_6@false;
}
ry = 0;
Size visibleSize = Director::getInstance()->getVisibleSize();
s = Sprite::create("HelloWorld.png");
s->setAnchorPoint(Vec2(0,0.5f));
s->setPosition(visibleSize.width / 2,visibleSize.height / 2);
addChild(s);
scheduleUpdate();
@H_403_6@return @H_403_6@true;
}
实现update函数:
void HelloWorld::update(float dt){
//s->setPositionZ(s->getPositionZ() + 1);
ry++;
s->setRotation3D(Vec3(0,ry,0));
}
运行,完成!