• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Achievement icon position based on instance number

T

ThePropagation

Guest
I have a game where you can get multiple achievements at one time, and it makes an icon appear in the top right. but they all are in the exact same position and overlap one another.

How can I make it so the if the object is over another one to make it move down and when the first one disappears, move up?

I tried position = instance_number(obj) but if 2 achievements appear after one has been destroyed that leaves one overlapping another and one under that one, I need to manipulate depth and y position to know when it's the earliest one made, and move that one into top right (example, position 0) and have the second earliest one be in position 1.

I think I'll use timers now that I'm typing it out but any other thoughts? Thanks.
 

obscene

Member
At some point you may want to make a UI object that is always drawing stuff to the GUI layer like this, textboxes, score, whatever. From an object like that it would be very easy to do this in a loop using 'with'. If you used instances for your achievements, make them invisible and then draw them from your UI object....

Code:
var xx=(wherever your first one goes);
var yy=(wherever your first one goes);
var height=(how far down to draw each one);
var offset=0;
with (obj_achievement)
     {
     draw_sprite(sprite_index,0,xx,yy+offset);
     offset+=height;
     }
 
T

ThePropagation

Guest
I guess I should have been more clear with my setup. I have an object called objAchievement that uses a script, so whenever my achievement variable goes over a certain amount (Kills or coins collected etc) It runs the script. The script determines the text that is displayed (ex. You killed x enemies!) then creates the achievement object with that message in it. Is there a way to tell which one is in position one, then when it is destroyed, that 2 moves to one and if any more show up to put them below the first? Just trying to order them properly with depth and y value. Thanks
 

obscene

Member
Made a small test project to demonstrate. This puts the newest achievement at the top and the older ones gets pushed down. If you wanted to reverse it, you could get the instance_number, calculate the position of the last one and then offset a negative amount to work back towards the top.

If nothing else it will demonstrate the principle and might lead you to figure out your own way to do it.

https://drive.google.com/open?id=1Y6sU9fDbGJeTwIAVPP1DZyMldRMQ1itc
 
T

ThePropagation

Guest
Thank you for that. Sometimes I run into a problem, and I think way too hard to come up with a solution that's actually simple. Thanks again.
 
Top