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 / getSpriteHit doesn't work with animated sprites?

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 19th Mar 2014 23:47
I use getSpriteHit() to detect the pointer clicking on an image (a button). I changed the sprite to an animated sprite so I can have separate images for the on and off states of the button. Now getSpriteHit() doesn't register the sprite.

I've tried manually setting the sprite shape defining the box, but it still isn't detected.

xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 20th Mar 2014 03:10 Edited at: 20th Mar 2014 03:13
I use the same way, and it work perfectly.
Have you done a Button Manager with array or vector?
Cycle it and get if the hit is in the box.

Do in this way:
- Is the pointer pressed?
- Is the pointer released?
- Is the hit inside the button rectangle?
- Call the function

Ah, don't use SHAPE 3 on the button, but the BOX one!!

Long life to Steve!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 20th Mar 2014 16:46
I did use shape 2 (box) to auto create it. Then I manually defined the box with setShapeBox. Just wouldn't work. My buttons are in an array that I loop through. What I ended up having to do was the old fashion is my pointer within this box area. Not a huge issues since I'm looping through all the buttons anyway.

Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 20th Mar 2014 17:07
I always use GetSpriteHitTest(id, GetPointerX() , GetPointerY()) for user input. GetSpriteHit always gave odd results when sprites are layered on top of each other. I think it works better when sorting is explicitly turned on, but I always felt more secure with GetSpriteHitTest on user input.

Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 20th Mar 2014 22:02
I always do as naphier

The one you use only detects the sprite at the top also.

Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 21st Mar 2014 01:07
[quote]The one you use only detects the sprite at the top also.[center]
That's fine with me since I don't care about selecting sprites hidden under other sprites.

Login to post a reply

Server time is: 2024-11-25 03:23:45
Your offset time is: 2024-11-25 03:23:45