Does anyone know of an easy way to animate a CCMenuItem when the mouse passes over it.
I have read this thread:
Cocos2d CCMenuItem animation upon selection
which seems to cover Cocoa Touch but does not work for me with OS X.
The cocos2d reference lists this method of CCMenuItemImage: which I used this way:
CCMenuItem *beginButtonMenuItem = [CCMenuItemImage itemWithNormalImage:@"BeginButton3.png"
selectedImage:@"BeginButtonSel3.png"
target:self
selector:@selector(beginButtonPressed:)];
However that menu item does not respond by changing the image when the mouse passes over, only when clicked.
the CCMenuItem reference has this method:
- (void) selected, stating "The item was selected (not activated), similar to "mouse-over""
but has no sample code ...
Can anyone help implement this?
Thanks
I found it to be quite easy to make the
CCMenu
change anyCCMenuItem
to theselected
state when the mouse passes over it, giving it a hover effect. First, make sure you've set[window_ setAcceptsMouseMovedEvents:YES];
Then add this function to
CCMenu.m
(perhaps just afterccMouseDragged
definition):