메뉴 건너뛰기

자유롭게 이야기를 적는 공간

리스너로 this를 넘겨줬는데
터치로 인해 실행되는 순간에 셀렉터에선 포인터 주소가 4바이트 밀려 있음...
이건 도대체 무슨 문제인가?

class CommandButton
{
public:
virtual void createButton(cocos2d::CCNode* node, int x, int y, int tag) = 0;
};

class KillMonster : public CommandButton, public cocos2d::CCObject
{
private:
MainMenuInterface* main;

public:
void execute(CCObject* pSender);
void createButton(cocos2d::CCNode* node, int x, int y, int tag);
KillMonster(MainMenuInterface* m);
};

////////////////////////////////////////////////////////////////////////////////////////////////////////
//Kill Monster

void KillMonster::execute(CCObject* pSender)
{
this->main->KillMember(); // <- 어째서인지 이 때는 this가 0x024afa1c. 4바이트 밀려버렸다!!
}

void KillMonster::createButton(cocos2d::CCNode* node, int x, int y, int tag)
{
CCMenuItemImage* menu_item = CreateMenuItem(node, "images/button.png", "images/button.png", 
                                                                                 "Kill", x, y, 32, ccc3(255, 255, 255), 10, tag);
if(menu_item)
{
menu_item->setTarget(this, menu_selector(KillMonster::execute)); // <- 이 순간에는 this가 0x024afa18임
}
}

KillMonster::KillMonster(MainMenuInterface* m)
:main(m)
{
}

조회 수 :
610
등록일 :
2013.09.09
20:42:28 (*.75.88.173)
엮인글 :
게시글 주소 :
https://hondoom.com/zbxe/index.php?mid=free&document_srl=703159

똥똥배

2013.09.09
21:01:41
(*.75.88.173)
해결

class CommandButton : public cocos2d::CCObject
{
public:
virtual void execute(CCObject* pSender) = 0;    //<- 이게 없는 게 문제였음
virtual void createButton(cocos2d::CCNode* node, int x, int y, int tag) = 0;
};

class KillMonster : public CommandButton
{
private:
MainMenuInterface* main;

public:
void execute(CCObject* pSender);
void createButton(cocos2d::CCNode* node, int x, int y, int tag);
KillMonster(MainMenuInterface* m);
};

Kadalin

2013.09.10
02:03:58
(*.206.156.3)

....내가 방금 뭘 본 거지.

List of Articles
공지 (대피소) 혼돈과 어둠의 디스코드
노루발
107   2023-09-05 2023-09-05 16:05
공지 글 작성을 위해서는 회원 가입이 필요합니다.
노루발
4674   2016-02-22 2021-07-06 09:43