Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Annoying sprite glitch - cant click or interact unless position is 0,0

Author
Message
Midget Blaster
AGK Developer
10
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 1st Oct 2016 11:54


That is my code. Simple right? Now, look at this problem.



I am trying to press that sprite. Gamestate is printed up the top. When I click the sprite, it does not change the gamestate, which makes no sense. Now, if I change the sprites position to 0,0



?? Here it works perfectly fine. Now, on my title screen I had the exact same issue. I got angry and so replaced it with a button. I would do the same for this but the max amount of buttons you can have is 12 and that is not enough. Any solutions? Anyone ever have the same problem? I could not find this anywhere else on the forum. Thanks!
CJB
Valued Member
22
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 1st Oct 2016 13:22
We would need to see more of your code to know what is going wrong. In principle it should work fine. Here is a stripped back example that works:



Keep in mind that GetSpriteHitTest uses world coordinates, so if you have changed the view offset, or zoom then you'll need to adjust GetPointerX/Y using ScreenToWorldX and ScreenToWorldY.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Midget Blaster
AGK Developer
10
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 1st Oct 2016 22:04
Well, I have this SetViewOffset ( 0, y# - 600 ) but its set to 0 in the main menus case.

Can you tell me more about "float ScreenToWorldX( x )" Would I have to do something like

if GetSpriteHitTest ( playlevel , ScreenToWorldX(GetPointerX()) , ScreenToWorldY ( GetPointerY () ))
Midget Blaster
AGK Developer
10
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 2nd Oct 2016 12:12
I have noticed that it works anywhere on the X scale, but on the Y scale it won't work. Any other ideas?
CJB
Valued Member
22
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 2nd Oct 2016 21:23
Quote: "Would I have to do something like

if GetSpriteHitTest ( playlevel , ScreenToWorldX(GetPointerX()) , ScreenToWorldY ( GetPointerY () ))"
Exactly it!

Not sure what to say. Here's the same stripped-down example using view offset on the y scale and screentoworldx/y:



move your mouse pointer over the box. Does it detect the hit? Works fine for me.
V2 T1 (Mostly)
Phone Tap!
Uzmadesign
Midget Blaster
AGK Developer
10
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 4th Oct 2016 19:26
Yes, it does detect the hit. But it doesn't do anything when it is being pressed.


I've tried everything I could think of :p
SoftMotion3D
AGK Developer
20
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 4th Oct 2016 21:34 Edited at: 4th Oct 2016 21:39
Getpointerpressed will indicate a value only for the initial frame its detected on.

Getpointerreleased will give you a value only on the frame its detected on

I think you may be lookin for getpointerstate? That will hold a value as long as your pointer is pressed on the screen

Also need a sync command called to update those agk commands to function properly.... Some ideas of what may be missing...

Login to post a reply

Server time is: 2026-07-20 09:34:32
Your offset time is: 2026-07-20 09:34:32