The schedule update callback to load the texture to the existing SpriteImage addChild disappears.
pc is fine,
The problem occurs only on Android.
업데이트콜백 스케줄에서 텍스쳐를 로드하여 addChild를 하면 기존 SpriteImage가 없어집니다.
pc에서는 괜찮고
안드로이드에서만 문제가 발생합니다.
bool GameState::init()
{
if ( !CCLayer::init() )
{
return false;
}
CCSprite *sprLand = CCSprite::create("a_playStage.png");
sprLand->setPosition(ccp(_GAME_WIDTH / 2, _GAME_HEIGHT / 2));
this->addChild(sprLand);
this->scheduleUpdate();
this->InitMoveArea(); //good visible, show
return true;
}
void GameState::InitMoveArea()
{
const float rectSize = 74;
for(int y = 0; y < _BOARD_ROW_MAX; ++y)
{
for(int x = 0; x < _BOARD_COL_MAX; ++x)
{
_moveArea[y][x] = Sprite::create("a_rect.png");
_moveArea[y][x]->setPosition(_BOARD_X + (x * _BOARD_UNIT_SIZE) + 0 - 2,
_BOARD_Y + (y * _BOARD_UNIT_SIZE) + 0 + 2);
_moveArea[y][x]->setAnchorPoint(Point(0.5f, 0.5f));
_moveArea[y][x]->setScale(rectSize / 64.0f, rectSize / 64.0f);
_moveArea[y][x]->setColor(ccc3(255, 0, 0));
_moveArea[y][x]->setOpacity(128);
//_moveArea[y][x]->setOpacity(0);
this->addChild(_moveArea[y][x]);
}
}
}
//problem. The image(Texture) is not visible properly
void GameState::update(float dt)
{
if(_pushUnitIndex != 0)
{
int col = GET_COL_TO_BOARD_ID(_pushUnitIndex);
int row = GET_ROW_TO_BOARD_ID(_pushUnitIndex);
const float rectSize = 74;
_moveArea[row][col]->retain();
_moveArea[row][col] = Sprite::create("a_rect.png");
_moveArea[row][col]->setPosition(_BOARD_X + (col * _BOARD_UNIT_SIZE) + 0 - 2,
_BOARD_Y + (row * _BOARD_UNIT_SIZE) + 0 + 2);
_moveArea[row][col]->setAnchorPoint(Point(0.5f, 0.5f));
_moveArea[row][col]->setScale(rectSize / 64.0f, rectSize / 64.0f);
_moveArea[row][col]->setColor(ccc3(255, 0, 0));
_moveArea[row][col]->setOpacity(128);
this->addChild(_moveArea[row][col]);
_pushUnitIndex = 0;
}
}