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 - Even for invisble sprites

Author
Message
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 17th Sep 2011 21:40
I'm not sure if this is a bug, or its intended purpose, but when you set a Sprite to invisible, GetSpriteHit still returns the invisiblt Sprite.

For example, I am using a Sprite as a button, and although I have set it to invisible, if I click the area where the button would be displayed (if it wasn't invisible), GetSpriteHit returns the sprite id. Surely if the Sprite is invisible you shouldn't be able to click it? No?

What do you think?
Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 17th Sep 2011 22:20
Hmmm... I've found a work around, simply look for the visibility first using GetSpriteVisible...



Thanks all the same...
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 17th Sep 2011 22:24 Edited at: 17th Sep 2011 22:25
Invisible sprites can be usefull, if you walk into an invisible wall, it still hurts, You should move the sprite to some unused coordinates, like -5000,-5000 if it should not be "active", and move it back when you need it again. You can also use the setspriteactive command, but I'm not sure how it will work with collisions and physics, I had problem using the virtual button active/inactive command, so I use the -5000,-5000 trick.

----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.
MadTinkerer
14
Years of Service
User Offline
Joined: 21st Nov 2010
Location:
Posted: 18th Sep 2011 06:30
In a project I made for a class, invisible sprites were used for a ton of things.

Detecting whether the player was in line-of-sight of an enemy (no raycasting functions in the language I was using, and it was an introductory course, so I didn't know how to do it myself yet)

Detecting whether the player sprite was in a particular position so an event could trigger.

Plopping down a "Hey, AI, the explosion will be this big" invisible sprite so if they detect that they collide with the sprite they'll try to avoid the explosion.

A "use item" invis-sprite next to the player sprite which checked if usable items collided with it when the player hit the button.
XanthorXIII
AGK Gold Backer
13
Years of Service
User Offline
Joined: 13th May 2011
Location:
Posted: 19th Sep 2011 17:05
Probably should use Zone Collision in lieu of Invisible Sprites for a lot of this stuff.
http://www.appgamekit.com/documentation/examples/sprites/11_zone_collision.htm

Although I still need invisible sprites or hidden sprites when flipping around stuff. But the above would be good if say your character falls into a lava trap.
Rich Dersheimer
AGK Developer
15
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 19th Sep 2011 18:21 Edited at: 19th Sep 2011 18:22
I'm just moving my sprites off-screen, as impetus73 suggested. It's even saving me some commands, as a SetSpritePosition() takes the place of both SetSpriteVisible() and SetSpriteActive().

Login to post a reply

Server time is: 2024-11-22 05:25:00
Your offset time is: 2024-11-22 05:25:00