How i make a conditional branch to check if a image is clicked or hovered by mouse, i want to make some buttons on screen, when thi button is hovered it change color, and when ia cliked it open any menu
Check if image is clicked or hovered
RPG Maker MV SupportIf you have no extra plugin for such things, you can look into the rpg.core default plugin for "TouchInput":
(my knowlegde about this stuff is very limited)
some examples as far i understand them:
(anyone pls correct me if i am wrong)
i guess you will need a script that checks the position of the "img" & the position of "TouchInput".. and if they are the same while mouse is moving..
=> that would mean "mouse hovers over img"
---
with an extra condition about "TouchInput.isTriggered()" , when the other requirements explained above apply , ..
=> that would mean "If mouse cliks on img"
(in such case the "mouse is moving condition" might be not required, but i am not sure)
edit
sry i am not sure about the code for "change color" ,..
..and the code for "open menu" depends on which menu you wanna open i guess.
(my knowlegde about this stuff is very limited)
some examples as far i understand them:
(anyone pls correct me if i am wrong)
JavaScript:
if (TouchInput.isMoved())
// if condition for "if mouse is moving"
TouchInput._x ;TouchInput._Y;
// thats the x & y data of your mouse
TouchInput.isTriggered()
// thats about clik usage, you can also add stuff to the array,
// but i dont know proper examples,.. these might work
TouchInput.isTriggered('ok'); TouchInput.isTriggered('escape');
// not tested, but i saw these somewhere else..
//..perhaps someone else can explain that part better.
i guess you will need a script that checks the position of the "img" & the position of "TouchInput".. and if they are the same while mouse is moving..
=> that would mean "mouse hovers over img"
---
with an extra condition about "TouchInput.isTriggered()" , when the other requirements explained above apply , ..
=> that would mean "If mouse cliks on img"
(in such case the "mouse is moving condition" might be not required, but i am not sure)
edit
sry i am not sure about the code for "change color" ,..
..and the code for "open menu" depends on which menu you wanna open i guess.
Ye i found this commands in a script call list, i just dont know how to use it
If i can use something like
"if $gameScreen.picture(1) is TouchInput.isTriggered()"
Color image and open menu is not important right now
If i can use something like
"if $gameScreen.picture(1) is TouchInput.isTriggered()"
Color image and open menu is not important right now
Unfortunately the way the standard MV is setup Touch._x & Touch._y don't even change unless the mouse is pressed or screen is touched. This is also the case with the isMoved function.
So basically what that means is that wouldn't help with hovering since there would be no way of telling if something "hovered".
Instead in my plugin below I aliased the function _onMouseMove of TouchInput to store directly from the source...
Here's what I'm working on for this...
It's still in it's very early stages, and I need to add proper parameters but so far it seems to function pretty well.
[v0.10] CTB_YEP_PictureCommonEventEx Plugin: Click Here to Download
Only works for picture 1 as of right now and filenames are coded directly into the code.
Use this for click/release/etc.
Picture Common Events (YEP) - Yanfly.moe Wiki
My plugin is an addition to Yanfly's though it can also be used on it's own. It does a few things the most notable will be hover functionality but also adds the feature of pixel perfect detection.. so if the pixel is transparent it won't activate the click/trigger/hover/etc.
Well anyways yeah still a bit to go but when it's done it should do as needed for you.
This is the way that's currently setup:
This is what it looks like in action:
My plugin still has quite a bit of work to be done but that's basically what you're looking to do right?
@ct_bolt
thx for the info, i guess your plugin will be the better choice as soon its finished, but your coding style is allready hard to read for me^^
(above my knowledge in some cases)
edit.
i realize i made a mistake on this:
the xy data wont help because on the picture thats just where the picture has its anker.. we dont know all pixel-xy position of the whole img
thats why my solution wont work^^
(thats why i deleted my old code from this posting)
thx for the info, i guess your plugin will be the better choice as soon its finished, but your coding style is allready hard to read for me^^
(above my knowledge in some cases)
edit.
i realize i made a mistake on this:
the xy data wont help because on the picture thats just where the picture has its anker.. we dont know all pixel-xy position of the whole img
thats why my solution wont work^^
(thats why i deleted my old code from this posting)
its just what im looking for, but i need use more than one image.
is not possble to do something like in MZ?
[RPGMZ]Event, mouse over the image
Hi guys, I would like to know if without plug-in it is possible to make sure that when the mouse over an image passes it behaves as I want. Waiting for your eventual response, I wish you a good day.
forums.rpgmakerweb.com
Original thread: https://forums.rpgmakerweb.com/threads/check-if-image-is-clicked-or-hovered.152284/