1
2
3
4
5
6
7
8
9
10
11
12
13
|
//
//获取精灵的CCImage
Image*HelloWorld::createImageFromSprite(Sprite*sp)
{
Sprite*pNewSpr=Sprite::createWithSpriteFrame(sp->getSpriteFrame());
pNewSpr->setAnchorPoint(Vec2::ZERO);
RenderTexture*pRender=RenderTexture::create(pNewSpr->getContentSize().width,pNewSpr->getContentSize().height,Texture2D::PixelFormat::RGBA8888);
pRender->begin();
pNewSpr->visit();
pRender->end();
return
pRender->newImage();
}
//
|