cocos2dx Sprite的多种创建方法

1.通过文件创建

Sprite *bg = Sprite::create("backGround.jpg");

2.通过图片的某个区域创建

   SpriteFrame *frame = SpriteFrame::create("pean.jpg", Rect(, , , ));
Sprite *pean = Sprite::createWithSpriteFrame(frame);
bg->addChild(pean);

3.通过texture2d纹理创建(用这种方法的少)

     Image *image = new Image();
image->initWithImageFile("pean.jpg"); Texture2D *texture = new Texture2D();
texture->initWithImage(image); Sprite *pean = Sprite::createWithTexture(texture);
bg->addChild(pean);

4.用SpriteFrameCache(plist文件通过zwoptex创建)

 SpriteFrameCache::getInstance()->addSpriteFramesWithFile("person.plist");

 SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName("navigationbar_back.png");

 Sprite *pean = Sprite::createWithSpriteFrame(frame);
bg->addChild(pean);
上一篇:声明:function FileSetAttr ( const FileName : string


下一篇:WinForm应用程序中实现自动更新功能