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 Question

Author
Message
Talairina
18
Years of Service
User Offline
Joined: 9th Jan 2006
Location: United Kingdom
Posted: 6th Jan 2012 15:19
Is there anyway to get the text id used for a sprite when using GetSpriteHit if your using the following way to setup your sprite;



The command when used like so;


Returns the number of the sprite not any text id such as 'spr_button_end_turn' from my previous example. Since this number is assigned by AppGameKit and not yourself it could be anything and would be very difficult to track down if your using say 500-600 sprites at once and need to check for 'touches' on them. If I'm not clear in what I'm asking just say I'll and try and explain better. Lack of coffee and all means I'm prone to mistakes =)
mr_d
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Mar 2007
Location: Somewhere In Australia
Posted: 6th Jan 2012 16:30 Edited at: 6th Jan 2012 16:40
let me give you 2 answers that I can see for what I think you are trying to do...
1st is that there is the other form of declaring sprites that will give you control of what the number of the sprite actually is, so instead of

you could define it as

so that if the GetSpritHit command returns 1 you know that this is actually "spr_button_end_turn".

Although true, I don't think this is what you are after.
The 2nd answer is to just manage your own sprites in an array
e.g. spritearray[500]
where the index would represent your actual sprite numbers and the content of the array at that index would be the sprite text. so you'd have
this may get a bit messy if you have hundreds or thousands of sprites, but in principle it should work...
hope I make some sort of sense here

Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 6th Jan 2012 17:00 Edited at: 6th Jan 2012 17:11
So you're looking for a way to return the variable that contains the sprite index of the touched sprite?

I don't think there is a way to do this the way you want.

There are a number of ways around this.

I doubt you would assign 500-600 sprites manually using unique variables (as in your example code), more likely they would be stored in an array, in which case you could loop through the array.

You could assign the sprite indexes yourself, using the alternate format CreateSprite ( index , image), but again you would probably store these in an array.

AGK assigns sprite indexes sequentially so you can use the index itself to calculate an array position - providing you create the sprites in array order.

Array position = Sprite Hit index - First Sprite Index

EDIT: Simultaneous posted with "mr_d" (above) which is why I appear to pretty much repeat what he posted

Login to post a reply

Server time is: 2024-11-22 20:13:19
Your offset time is: 2024-11-22 20:13:19