How to trigger a mouse hover event on a MenuItemImage

I am aware of how to make an image perform a certain action, but how do I run an action on a menu item image when a mouse is hovering it? (I don’t want to change images, I want it to sort of vibrate(which I will achieve via moveby))

Please read the API docs for MenuItemImage.

thank you, I’ve been searching the web for 2 days!

You should have read the API-Docs first.

Stop web searching and wasting time. You wasted 2 days when the answer is right in the API-Docs.

When you need help:

  1. API-Docs
  2. cpp-tests
  3. search these forums a few times using various strings.
  4. post on these forums
  5. perhaps a quick web search.

I’ve did run the cpp tests, it provides valuable information on your deliverables, but very basic info in the ui which wasn’t new to me

just a clarification on the API’s syntax, when it says ‘xyz will affect the node’s xyz’ does that include buttons?

The API-Doc also tells you this. Plus you can always look at the MenuItemImage in the source if it is easier for you to read source than API-Docs.

Screenshot%20from%202019-01-02%2006-00-48

Edit: This is a teach a man to fish moment. Please know that at your age we need to teach you how to find answers on your own. If we don’t you will end up a programmer that really can’t program, except by stitching together the code of others.

Do you have an iPhone? Dash is a free docset app. Cocos2d-x docs are available. Dash for IOS on APP Store

I see. Unfortunately I use an android device, but I do my best to refrain from asking what I don’t need to

FWIW, I think most people use the most simplest resource they can. Google is usually the best resource for answering questions, even if it eventually points to API-Docs or SO or here or whatever.

I don’t think there is any out of the box solution for mouse hover. API won’t help here.

You have to get mouse position and check if it intersects the button’s bounding box.

I know but HOW do I do that?

 auto mouseListener = EventListenerMouse::create();
    mouseListener->onMouseMove = [=](EventMouse *event){
        Point mousePosition = Point(event->cursorX, event->cursorY);
       if(playButton->getBoundingBox().containsPoint(mousePosition){
      /////do something
       }
        
    };
    _eventDispatcher->addEventListenerWithSceneGraphPriority(mouseListener, this);

mark it as solution so it helps others as well.

MenuItemImage has selected. If I can today I will try this out.

sorry for the late solution mark, many thanks Bilal

menu item has no mouse code inside it… similar means its an example of mouse over
And if you look at the code of selected()
it only does what its suppose to do if it was to be selected. and display selected image.

MenuItem has normal, selected and disabled image.

Yup, I will test this. Your solution will surely work. The API-Doc description should be corrected if this doesn’t work as it says. The item was selected (not activated), similar to “mouse-over”.

Thanks for chiming in.