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 / Issue with clicking sprite

Author
Message
Midget Blaster
AGK Developer
8
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 6th Mar 2017 17:25
So I am trying to click a sprite. But I have a problem


If I remove the getpointerpressed()=1 and put my mouse under it "Hit!" Is printed. Why does it not work if getpointerpressed() is added at the start? I have tried this with getpointerpressed/released/state = 1

thanks
Crazy Programmer
AGK Developer
20
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 6th Mar 2017 17:42
Shot in the dark but try this.
Download My Games for Android. Made with AGK.
Jellyfish Dive- https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
Brick Destroyer - https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_BrickDestroyer
Ping Bong - https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_Pong_Ping_Bong
Midget Blaster
AGK Developer
8
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 6th Mar 2017 17:45
@Crazy Programmer Thanks for the fast response but no luck :/
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Mar 2017 17:52
GetPointerPressed() happens for only one cycle. Then it returns back to 0.

Did you mean to use GetPointerState(), which remains at 1 while the mouse button is down?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Midget Blaster
AGK Developer
8
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 6th Mar 2017 18:02
@BatVink Yes, I have tried that too. A weird problem is, that it works if the sprites position is 0,0, but only if I press the left half of the sprite, regardless if I have screentoworld enabled. Ive had this problem about a year ago too. Its a very inconsistent bug because in my other game, is have


which works perfectly, but does not work in my current preoject.
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 6th Mar 2017 22:11
Are you zooming or offsetting the view? If so, you'll need to use screentoworldx(getpointerx())... also, I find it very useful to assign sprites to groups and use getspritehitgroup.
i.e.



Also be aware that these collision detection commands will use the shape of the sprite for collision, not necessarily what you can see. SetPhysicsDebugOn() could help.
Midget Blaster
AGK Developer
8
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 7th Mar 2017 08:31
I have used screentoworldx before and it didn't help. The view offsets throughout the game but in this main menu it stays at 0,0
This is the sprite

the sprite is at 0,0. the red part on the right if pressed does nothing, but the left side works

However, if I use getpointerstate = 1 and press and hold onto the working side of the sprite, then drag it onto the right side, it works on the red part, until i take my cursor off and press again the right side doesnt work.


Also it does not work if sprite position is anything other than (0,0)
Is there something I'm doing wrong? I tried setting it as a physics object, SetPhysicsDebugOn() and the outline of the sprite covered the whole thing but yet again only the left side worked.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 7th Mar 2017 08:56
What happens if you do this?
Signature removed by mod because it's larger than 600x120... please resize and try again.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 7th Mar 2017 15:35
did you used advertising with CreateAdvert ?
AGK (Steam) V2017.02.28 : Windows 10 Pro 64 Bit : AMD (17.2.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 7th Mar 2017 17:23
Quote: "did you used advertising with CreateAdvert ?"
Haha! Yes, "invisible" ads can prevent clicks from working! Good thinking Markus.
Midget Blaster
AGK Developer
8
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 7th Mar 2017 20:55
@Mobiius Same as last time, when I do that only the left half works when pressed, as you can see with the faint "Hit!" print.


Again, the right side doesnt work.

@Markus & @CJB I don't have any adverts. Even if I did, I never use create advert, only ShowFullscreenAdvertAdMob()
Midget Blaster
AGK Developer
8
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 7th Mar 2017 20:57
If it helps, could it be anything related to my early set-up? Maybe a function that messes with other things?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 7th Mar 2017 21:50
you should extract this part and make a Test() Function which you call direct after SetPhysicsDebugOn()
AGK (Steam) V2017.02.28 : Windows 10 Pro 64 Bit : AMD (17.2.1) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
PSY
Developer
8
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 8th Mar 2017 00:50
Use GetSpriteHit to find out the ID of the sprite that is hit.

Maybe there's another invisible sprite with a depth lower than the playbutton, and this sprite is partially overlapping the playbutton.
PSY LABS Games
Coders don't die, they just gosub without return
Midget Blaster
AGK Developer
8
Years of Service
User Offline
Joined: 7th May 2016
Location:
Posted: 12th Mar 2017 00:47
So after ALL this time, turns out I had an invisible joystick taking up most of my screen without setvirtualjoystick(1,0). Damn

Login to post a reply

Server time is: 2024-09-30 01:28:19
Your offset time is: 2024-09-30 01:28:19