Remove sprite not working?
-
After I load another map It says remove sprite operation cannot be do or something along those lines how do I do this?
-
I tried to use remove sprite and although it did remove the sprite it messed up my others (because I had multiple copies of it)
I found the best method is to simply move the sprite off screen. to something like setspritelocation(mysprite,-500,0)Hope that helps, sorry if it doesn't but I'm sure the experts will be along to help you soon.
-
Actually that's great thanks.
-
Not so great for the memory use...
even if we have enough
In any case, it shocks the coder in me ... -
@Electric-Dreams Steve has a fixed sized array of sprites that live throughout the lifetime of the program. So memory usage is static. Also, all removed sprites are eventually put back again at the start of the next level, or game.
To the original problem, you can do something along these lines - it has worked for me in the past, if it doesn't now then I'd like a small code sample to test.
nullSprite = createSprite(). // Do nothing with this sprite // create all the sprites you desire - but let's say we have one called player removeSprite(player) player = nullSprite // Everything carries on as it should
-
fixed sized array : ok, no memory problem !
In the futures updates, will we have any fonctions to dynamicly manage the array ?
What I mean ?
Removing any piece of an array and adding other ones.
For exemple, an enemy who get out screen should be remove of the array, and we could add some other as le difficulty grows. -
You can add elements now, there are other posts on the subject.
-
You can add elements, but can you remove elements? I wanted a stack type structure and ended up using a variable to keep track of the last relevant piece of information in my array and decreasing it each time I really wanted to remove an element from the end of the array. I don't imagine this was the most efficient method, but it worked.
-
Yes adding is possible, I already do it on my snake game when the snake grow.