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 / Retuning the name of the sprite clicked on.

Author
Message
Nickydude
Retired Moderator
17
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Look outside...
Posted: 16th Aug 2011 09:25 Edited at: 16th Aug 2011 09:27
I've created a sprite called spr_menu_1_normal, is it possible to do the following?



I've tried and it doesn't seem to register the click on that sprite. If I comment out the "if getspritehit..." line then the (global) click registers.

I reject your reality and substitute my own...
Mike Johnson
TGC Developer
21
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 16th Aug 2011 09:37
Might be down to local / global scope. Is the variable spr_menu_1_normal a global?
Nickydude
Retired Moderator
17
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Look outside...
Posted: 16th Aug 2011 09:40
Quote: "Might be down to local / global scope. Is the variable spr_menu_1_normal a global?"


Err... not sure, pretty new to this stuff. Here's the full code:



I reject your reality and substitute my own...
Nickydude
Retired Moderator
17
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Look outside...
Posted: 16th Aug 2011 10:43
Ok, this is odd, I changed

img_menu_1_normal = loadimage ("begin.png")

to

loadimage (1,"begin.png")

and

spr_menu_1_normal = createsprite (img_menu_1_normal)

to

createsprite (1,1)

and tried

if getspritehit (getpointerx(), getpointery()) = 1

but still no joy. After a bit of debugging it seems it's looking for sprite 10001! If I put

if getspritehit (getpointerx(), getpointery()) = 10001

it works! Am I doing something wrong creating the images / sprites?

I reject your reality and substitute my own...
Mike Johnson
TGC Developer
21
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 16th Aug 2011 10:45
The problem here is that GetSpriteHit is returning the ID of spr_menu_1_over as this sprite is being drawn above spr_menu_1_normal. It should really detect that this sprite is invisible and ignore it when GetSpriteHit is being used.
Nickydude
Retired Moderator
17
Years of Service
User Offline
Joined: 4th Nov 2006
Location: Look outside...
Posted: 16th Aug 2011 10:51 Edited at: 16th Aug 2011 10:54
Ahh! So even though sprites are invisible they are still being detected? So moving the over sprite would solve it? Thanks Mike, would never have thought of that.

Edit: Yup, that did the trick.

I reject your reality and substitute my own...

Login to post a reply

Server time is: 2024-04-19 19:08:43
Your offset time is: 2024-04-19 19:08:43