sprite



DrawNode* rect = DrawNode::create();
//rect->setAnchorPoint(Point(1,1));//这里个值没有用
rect->drawRect(Point(0,0),Point(100,100),Color4F(255,255,100));//这里的认anchorpoint值为0
//rect->drawRect(Point(300,300),Point(200,200),100));
//rect->setPosition(Point(100,100));//设置其位置
this->addChild(rect,1);

//Sprite* sp1 = Sprite::create();
//sp1->setTexture("menu_background.jpg");

//Sprite* sp1 = Sprite::create("menu_background.jpg");


//auto bath = SpriteBatchNode::create("Hello.png");
//Sprite* sp1 = Sprite::createWithTexture(bath->getTexture());

//根据缓存plist中的sprite frame来创建,这种用的比较多
//SpriteBatchNode* node = SpriteBatchNode::create("Hello.png");
//Sprite* sp1 = Sprite::createWithTexture(node->getTexture());

Sprite* sp1 = Sprite::createWithSpriteFrame(SpriteFrame::create("Hello.png",Rect(0,480,320)));
sp1->setAnchorPoint(Point(0,0));
//sp1->setPosition(Point(10,10));
sp1->setTag(100);
this->addChild(sp1,0);

schedule(schedule_selector(SpriteTest::callback),10);//调用时间


return true;
}

void SpriteTest::callback(float dt) { Sprite* sp1 = (Sprite*)this->getChildByTag(100); sp1->setTexture("HelloWorld.png"); sp1->setPosition(100,100); sp1->setRotation(-90);//这里的旋转没有时间设置而是直接到位的 }

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...