Hi everyone,
I’m having a problem with overloading draw() method from CCLayer,
CCSprite and CCTexture2D. I hope someone could help me.
The main problem is that the Texture doesn’t move, it’s remain static in screen, at
point (0,0) but i don’t understand why.
some related code:
void LayerGame::onEnter()
{
CCLayer::onEnter();
//i'm caching the textures
m_Tex1 = CCTextureCache::sharedTextureCache()->addImage("spr1.png");
m_Tex2 = CCTextureCache::sharedTextureCache()->addImage("spr2.png");
m_Tex3 = CCTextureCache::sharedTextureCache()->addImage("spr3.png");
m_Tex1->retain();
m_Tex2->retain();
m_Tex3->retain();
}
void LayerGame::draw()
{
CCLayer::draw();
CCSprite* spr1 = CCSprite::createWithTexture(m_Tex1);
//here i put static positions, but the sprites are moved constantly
//by calculations
spr1->setPosition( ccp(100, 200) );
//but the texture(s) are in position (0,0).!! :(
//the spr1->getPosition().x reports moving.
spr1->draw();
}
I missed some code for draw?.
what’s the problem with my code?
thanks to everyone.