i use menu item as below:
CCMenuItemImage *pSoundItem = CCMenuItemImage::itemFromNormalImage(
SoundONPic,
SoundONPic,
SoundOFFPic,
this,
menu_selector(HelloWorld::menuSoundOn_OffCallback) );
pSoundItem~~>setPosition~~>getWinSize.width~~ 150, 20) );
m_Sound_Item = pSoundItem;
m_Sound_Item~~>setIsEnabled( false );
m_Sound_Item~~>retain;
but menuSoundOn_OffCallback will not been invoked, i do not know why, so set item to be true:
m_Sound_Item~~>setIsEnabled( true );
ok, menuSoundOn_OffCallback could been invoked but only one time.
anybody know this??? thanks very much
ps: i also study the code of test application, there also is the same problem.
- The difference between setIsEnabled(false) and setIsEnabled(true):
When you call m_Sound_Item~~>setIsEnabled,the menu item will not handle any touch event.
So if you want menuSoundOn_OffCallback can be invoked,you must call this at first:
<pre>
m_Sound_Item~~>setIsEnabled( true );
2. Function menuSoundOn\_OffCallback be invoked only once:
We need to know what have you done in menuSoundOn\_OffCallback.Can you paste your code here?
Hm….Thanks very much.
i use like:
CCMenuItemToggle* pSoundItem = CCMenuItemToggle::itemWithTarget(
this,
menu_selector(HelloWorld::menuSoundOn_OffCallback),
CCMenuItemImage::itemFromNormalImage(SoundONPic,SoundONPic),
CCMenuItemImage::itemFromNormalImage(SoundOFFPic,SoundOFFPic),
NULL );
it’s ok.
@bin, thanks for your comments:
- The difference between setIsEnabled(false) and setIsEnabled(true):
* When you call m_Sound_Item->setIsEnabled(false),the menu item will not handle any touch event.*__
Not at all.
Best wishes for you! : )