将Sprite转换为Image。
// //获取精灵的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(); returnpRender->newImage(); } //原文链接:https://www.f2er.com/cocos2dx/347129.html