TNT Basic Forums > Feedback
read sprites "level" or Priority
< Last Thread     Next Thread >
Thread        Post A Reply

12-04-2007 16:04

Posted by:

Paris France

Find more posts by Maxime

If you have many sprites, it would be intersesting to read the priority of the sprite you click in : you generally want to select the upper one. I read the doc, and could not find this was possible, which obliges to generate complicated codes !
Thanks if you show me

12-04-2007 22:00

Posted by:

hertfordshire (England)

Click Here to Email allnodcoms   Find more posts by allnodcoms

Hi Maxime...

Welcome to the Forums. There is no such call to return the sprite priority of the selected image, but it's not difficult to implement, depending on the type of game you are working on.

A handy trick which works in many cases is to directly link the priority of the image to its Y coordinate, which you can get at run time. If you get several collisions then just poll to see which one has the greater Y value, and this is your top image. Might be worth a look?

The other, slightly more long winded way would be to hold an array of sprite priorities, element zero is the priority of sprite zero and so on. It takes more time to set up but runs quick enough during play, and if you are using different types and sizes of sprite it is the best option, especially if you intend to hold additional data as this can be added to the array rather than held separately.

I hope this helps, but if not, if you get back to us with a few more specifics as to what you are trying to do and why we will se what we can do...

Happy coding!

Danny (nod the mod)

12-13-2007 12:41

Posted by:

Paris France

Find more posts by Maxime


In fact, I'm trying to build a one player card game, where I have to move cards, or sets of cards from one pile to another. I have several piles, some "all cards at the same place", some with a "dy" between each card.
When I click on a card, I would like to select the highest one below the mouse. But I have no mean to know which is the highest ! So I managed with the place of the cards in the pile and the dy, which is the line of your suggestion of "using y"...
Then, I can increase priorities of the cards I move, to have them move above any other (and piles basements). But when I drop them somewhere, I would have liked to be able to put them back in a normal order by some short exchange (if not, I will have higher and higher priorities !). The only solution I found is to assign back all cards' priorities after a drop... This is not very beautiful, but does not seem to slow the game.
I must say also that the fact that arrays are one dimension only does not make thinhs easy. I would like to say "myCard=card [pileNumber, pilePlace], but I have been obliged to buils a ugly procedure with one array for each pile :

procedure readCard(int tp, int np) 'reads card np of tp pile
if tp=1 : carteLue=t2c1[np]
else if tp=2 : carteLue=t2c2[np]
else if tp=3 : carteLue=t2c3[np]
else if tp=4 : carteLue=t2c4[np]
else if ...
else if tp=23 : carteLue=t2c23[np] : end if
end proc

Hopely thanks for your help

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.