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 problem

Author
Message
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 5th Mar 2012 10:26
I started using GetSpriteHit.

Because of the order AppGameKit 106 draws sprites, GetSpriteHit is not returning the TOP-most sprite ID, but the LOWER-most ID.

I know that sprites will be drawn the "proper" order in 107.

But how can I solve this problem in 106?

Is there any simple way around it?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Mar 2012 11:00 Edited at: 5th Mar 2012 11:01
What about something like this (untested):

Edit: Just to explain, it goes through each hit sprite, moves it to the side then moves them all back again afterwards saving the last hit as "LASTHIT"

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 5th Mar 2012 11:18
Baxslash thanks a lot, but I just wanted to avoid having to loop through hundreds of sprites.

On the other hand I just check GetSpriteHitGroup() and this works correctly!!!!

TGC, please fix this for 107, make sure that the order sprites will be drawn, all different GetSpriteHit (Catg, Group, etc) work the same way!

Thanks a lot!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Mar 2012 11:22
Yes, using groups has saved me a lot of headaches. The method I posted should only check the sprites that are at a specific point on screen though so unless you have hundreds of sprites at one point on the screen it should be fine.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 5th Mar 2012 11:49
I hope TGC will fix this in 107, making all GetSpriteHit commands return the same values.

The order sprites are drawn in 107 is going to be the reverse of what is now (we learned this from the Blackberry release) so for wip projects we will have to cut & paste the sprite load, and reverse the order too.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 5th Mar 2012 11:59
On a side note, I think the GetSpriteHitGroup is a VERY POWERFUL command! Well done TGC!

Maybe GetSpriteHit could be expanded with an extra parameter to check for top most or lower most sprite! That would be totally awesome!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Mar 2012 12:01
The sprite grouping is also very powerful for raycasting.

What about something like:
getSpriteHitFirst()
getSpriteHitNext()

So it would be easy to check all the sprites hit?

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 5th Mar 2012 15:26
Great idea Baxslash! I don't need those myself, but just thought they could be powerful commands!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Mar 2012 15:36
Just realised that's what I wrote (one of them anyway)


Login to post a reply

Server time is: 2024-11-23 05:19:07
Your offset time is: 2024-11-23 05:19:07