【发布时间】:2015-01-06 10:27:45
【问题描述】:
// new image from png file
CCImage* img = new CCImage();
img->initWithImageFile( "2.png");
// new texture from image
CCTexture2D* tex = new CCTexture2D();
tex->initWithImage( img );
// create sprite
m_pSpr = CCSprite::create();
m_pSpr->setPosition( ccp( 100, 100 ) );
this->addChild( m_pSpr );
m_pSpr->setTexture( tex );
this is only ccimage to ccsprite but i want to get sprite to ccimage.
how to do
m_pSpr = CCSprite::create("2.png");
m_pSpr->setPosition( ccp( 100, 100 ) );
this->addChild( m_pSpr );
CCImage* img = new CCImage();
img->initWithImageFile( "m_pSpr getname");
【问题讨论】:
-
您尝试的内容详细说明
-
void hellworld:: istab(spritesp) {Image imgPtr = new cocos2d::Image(); imgPtr->initWithImageFile( "sp_sprite_name" );////如何设置 sprite 路径 const int width = imgPtr ->getWidth(); const int height = imgPtr ->getHeight();}
-
@himanshukalal 你能发布你的解决方案吗?
标签: c++ cocos2d-x cocos2d-x-3.0