Weird Mouse Clicking Issues

dreph

  • Posts: 142
Okidoke, so I've been dabbling with creating my own inventory system.  Let me start off by saying my logic is probably really gross and can be simplified, but everything works... unless I move the camera to another part of the scene...

Now I know what you're thinking, I didn't compensate for the camera with the drawing of my menu... but I did!  The inventory system spawns in the center of the screen, the slots and icons spawn in the correct position, visually.

However, the icons are only clickable in the inventory if I stay in the original camera position at 0,0.  If I move the player down, and say move the camera 50 pixels down, the icons and inventory spawn exactly where they need, but I have to click in an invisible space 50 pixels above the icon to use the item.  It's like the collider is staying at the original X,Y with the camera, but the icon (actor) is moving with the inventory as intended. 

For this prototype, I applied the event to use the icon directly to the actor, not a behavior, but as an event.  Just as simple as "If clicked and health not full, give a little health", and the same for the magic.  All of them work as long as I don't move the camera.

Here's a quick Gif Example.  First one is working in the original X,Y camera of 0,0.  The second is an example of what happens if I move down and try to click on the menu item.

Luyren

  • *
  • Posts: 2763
Turn on debug drawing, and use the print block to print the X and Y positions of the mouse when you click it, and the X and Y position of the actor you want to click when it is clicked. This should help pinpoint the problem. Also important to know if the display in the inventory is the actual actor, or an image of a created actor.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.

dreph

  • Posts: 142
To answer your question, it is an actor.  I did the debug draw and this is what I see.  Clearly it's the problem, but I don't understand what I am seeing, honestly. 

dreph

  • Posts: 142
I think it was literally the location of the mouse pointer was misleading me... that's what I get for trying this when I'm sick...

Mouse pointer was spawning in a different location than the mouse actually was...

Thanks for helpin' out! lol


dreph

  • Posts: 142
To answer your question, it is an actor.  I did the debug draw and this is what I see.  Clearly it's the problem, but I don't understand what I am seeing, honestly. 

So, the debug drawing helped me figure out where the original actor was drawn, but it also seems to leave a trace of the actor after every draw.  After about a dozen pauses, I notice some FPS drops.  Is there a way to clear up those drawing spaces?  Or should they just disappear if I "Kill" the actors after game is unpaused?

dreph

  • Posts: 142
I think it was literally the location of the mouse pointer was misleading me... that's what I get for trying this when I'm sick...

Mouse pointer was spawning in a different location than the mouse actually was...

Thanks for helpin' out! lol



I had figured out that my mouse and cursor didn't line up, however I found a weird issue.  It's working, but I'm curious:

I was only able to set the X and Y position of the cursor on the mouse cursor itself (the actor).  I had it set to "If alive, set X/Y coordinates to X/Y Mouse input + X/Y Camera" directly to the actor.  If I tried to set this in a scene behavior, it would only spawn it, and not follow the mouse (Even duing an "Updating" statement).  Any explanation for that? 

Luyren

  • *
  • Posts: 2763
Quote
If I tried to set this in a scene behavior, it would only spawn it, and not follow the mouse (Even duing an "Updating" statement).

Without looking at the code, it should be working. Might be a mistake on your end, such as forgetting to set an actor attribute for your mouse cursor?

As for the debug drawings, they should disappear after you kill an actor. If they are not, you might not be killing all of them when you close the menu.
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.