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.

Newcomers AppGameKit Corner / Deleting Sprites Or Positioning

Author
Message
Crazy Programmer
AGK Developer
14
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 13th Feb 2015 05:01 Edited at: 13th Feb 2015 05:57
//Boxes to Avoid

How can I find and delete every other sprite?
Or a function to position the sprites farther apart.
I need it to skip every other position.
First sprite at x# 750, next at 2250, next at 3750 next at 5250 and so on.

Thanks for your help in advance.

Edit: I palyed with it alil and got it done another way. Im still wondering tho for future purposes...How would you delete every other array or make it skip positions like that.
Is what iv found that im happy with.
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Feb 2015 09:42
I don't fully understand wht you are trying to do, but for this part...

Quote: "How would you delete every other array or make it skip positions like that."


You can use step in your for loop...

for n = 1 to 50 step 2

This will increase n by 2 each loop - 1,3,5,7,9...

For deleting array elements or other similar operations you should always work backwards. This is because as soon as you delete 1 element, all the others are renumbered and you will crash and burn before the end of the loop. By the time you get to iteration 26, you'll only have 25 elements in your array.

for n = 49 to 1 step -2
MyArray.remove(n)
next n


Quidquid latine dictum sit, altum sonatur

Login to post a reply

Server time is: 2019-08-25 16:19:08
Your offset time is: 2019-08-25 16:19:08