标签:
1.通过文件创建
Sprite *bg = Sprite::create("backGround.jpg");
2.通过图片的某个区域创建
1 SpriteFrame *frame = SpriteFrame::create("pean.jpg", Rect(0, 0, 300, 300)); 2 Sprite *pean = Sprite::createWithSpriteFrame(frame); 3 bg->addChild(pean);
3.通过texture2d纹理创建(用这种方法的少)
1 Image *image = new Image(); 2 image->initWithImageFile("pean.jpg"); 3 4 Texture2D *texture = new Texture2D(); 5 texture->initWithImage(image); 6 7 Sprite *pean = Sprite::createWithTexture(texture); 8 bg->addChild(pean);
4.用SpriteFrameCache(plist文件通过zwoptex创建)
1 SpriteFrameCache::getInstance()->addSpriteFramesWithFile("person.plist"); 2 3 SpriteFrame *frame = SpriteFrameCache::getInstance()->getSpriteFrameByName("navigationbar_back.png"); 4 5 Sprite *pean = Sprite::createWithSpriteFrame(frame); 6 bg->addChild(pean);
标签:
原文地址:http://www.cnblogs.com/wanyongjian/p/5060328.html