I am creating a series of 6 actions to flash a node (a large button), however it’s crashing with EXC_BAD_ACCESS (code=2):
(lldb) bt
* thread #1: tid = 0x5ecd30, 0x0000000100382ccc My Game Name`cocos2d::Ref::retain(this=0x00000001000837e8) + 176 at CCRef.cpp:85, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=2, address=0x1000837f0)
frame #0: 0x0000000100382ccc My Game Name`cocos2d::Ref::retain(this=0x00000001000837e8) + 176 at CCRef.cpp:85
frame #1: 0x000000010016ddec My Game Name`cocos2d::Sequence::initWithTwoActions(this=0x00000001700b8c00, actionOne=0x00000001700b8d20, actionTwo=0x00000001000837e8) + 396 at CCActionInterval.cpp:261
frame #2: 0x000000010016dc00 My Game Name`cocos2d::Sequence::createWithTwoActions(actionOne=0x00000001700b8d20, actionTwo=0x00000001000837e8) + 132 at CCActionInterval.cpp:162
frame #3: 0x000000010016de90 My Game Name`cocos2d::Sequence::createWithVariableList(action1=0x000000017009c390, args=0x000000016fd908d0) + 84 at CCActionInterval.cpp:205
frame #4: 0x000000010016de2c My Game Name`cocos2d::Sequence::create(action1=0x000000017009c390) + 44 at CCActionInterval.cpp:186
* frame #5: 0x0000000100083c3c My Game Name`GameScene::createButtonFlashAction(this=0x000000013dd100c0) + 132 at GameScene.cpp:178
frame #6: 0x00000001000837e8 My Game Name`GameScene::flashButtons(this=0x000000013dd100c0) + 52 at GameScene.cpp:172
at this line:
void Ref::retain()
{
CCASSERT(_referenceCount > 0, "reference count should be greater than 0");
++_referenceCount; // <--- HERE
}
Here is the code I am using:
void GameScene::flashButtons()
{
_leftButton->runAction(createButtonFlashAction());
_rightButton->runAction(createButtonFlashAction());
}
Action *GameScene::createButtonFlashAction()
{
return Sequence::create(
FadeIn::create(0.5f),
FadeOut::create(0.5f),
FadeIn::create(0.5f),
FadeOut::create(0.5f),
FadeIn::create(0.5f),
FadeOut::create(0.5f)
);
}
I am using Cocos2d-x v3 (github version; updated today). What am I doing wrong? It looks like the memory has been deallocated already?
Any help would be appreciated.