Not the texture load the update function

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;
}

}

please try
this->schedule( schedule_selector(GameState::update) );

@birdcpe25 It has not been resolved. [T o T]

which cocos2d version you using.

I use this thing
this->schedule( schedule_selector(GameLayer::update) );
for
void GameLayer::update(CCTime dt)
with no problem :frowning:

not sure if you have to change this arguement float dt
void GameState::update(float dt)
into
void GameState::update(CCTime dt)

I’m also beginner but it worth trying I think :slight_smile:

@birdcpe25 version is 3.0

Only problem with the Android mobile phone out there.

in header file

class GameState : public cocos2d::CCLayer
{
public:

	float _stateTick;
	bool _isPop;

	cocos2d::Sprite* _sprPause;
	cocos2d::Menu* _menuPause;


	cocos2d::Sprite* _redBall;
	cocos2d::Sprite* _blueBall;

	Sprite* _rectRes;

	int _selectIndex;

	GameState();
	~GameState();

	virtual bool init();                                //good, no problem
	static cocos2d::CCScene* scene();

	CREATE_FUNC(GameState);

	virtual void update(float dt);                     //problem!! [Texture, not addchild]


	void CallEnd();

	void LoadMenuPause();
	void CallBackMenuPause(Object* pSender);

	Character *_board[8][8];
	Sprite* _moveArea[8][8];


	//Sprite* _tempRect[8][8];

	bool onTouchBegan(Touch *touch, Event *event);     //problem!! [Texture, not addchild]
	void onTouchEnded(Touch *touch, Event *event);

	void SelectUnit(int boardIndex);


	void InitMoveArea();
	void OnMoveArea(int boardIndex);
	void OffMoveMoveArea();
};

Im not 3.0 user but please take a look
[[http://stackoverflow.com/questions/19748790/cant-get-touch-to-work-in-multi-platform-cocos2d-x-app]]

from what i’ve posted

virtual void update(float dt);
remove vitual
and add schedule in RE#1

add onEnter to register Touch event and see if it work or not

@birdcpe25 Not been resolved.

What’s the problem :frowning:

could you upload your cpp and h file after all have been changed, I’ll try edit it.

cpp file
very dirty code :<

@birdcpe25 header file

origin

After adding texture
Trouble with Android

help me :frowning: