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);