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.

Author
Message
BobMarilyn
15
Years of Service
User Offline
Joined: 29th May 2011
Location:
Posted: 30th May 2011 03:47
I am trying to work with collisions. I can get the collison to register with the code. I then desire to place another sprite over the sprite that has had the collison at the same coordianted. Tank than tank blownup (two sprites). How do I get rid of the first sprite Tank. Can I then reload the first sprite later??

Actually two questions. Thanks for any help.

Bob Russo
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 30th May 2011 06:22 Edited at: 30th May 2011 06:24
With the SPRITE command you can use exactly the same sprite number but change the image that it shows (it's how we make animated sprites the old way... without using the CREATE ANIMATED SPRITE command).

Syntax: SPRITE SpriteNumber,x,y,ImageNumber



Tom0001
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location:
Posted: 3rd Jun 2011 07:32
@Grog Grueslayer, Nice snippet, but it might be a tad excessive for a tank blowing up.

@Bobmarilyn, Despite the fact that what I just said might have seemed like criticism, Grog's method is actually really good. You could either use that or you could have the explosion sprite position over the tank sprite's current location first, then either delete the sprite or move it to some obscure co-ordinate that's off-screen if, for some reason, you don't mind it being kept in memory.
enderleit
19
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 3rd Jun 2011 08:28
Or HIDE SPRITE

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Jun 2011 17:58 Edited at: 3rd Jun 2011 18:11
@ Tom0001:

It's just a quick example of how changing the image number but keeping the same sprite works. All he really needs from that code snip is the SPRITE command with the image number as a variable.


@ BobMarilyn:

Lets say you use TImage for the current image number of the tank sprite. When you draw that tank use only one SPRITE command and just change the variable TImage when you want to replace that normal looking tank to the blown up tank (SPRITE 1,PlayerX,PlayerY,TImage).

Image numbers:
1 = Normal Tank
2 = Blown Up Tank
3-10 = Explosion

How to order it:
1. TImage=1 (shows normal tank)
2. Show explosion animation (using a different sprite than the tank)
3. TImage=2 (shows blown up tank)
4. Move explosion sprite off screen


@ Everybody:

I felt I should add the new method for animating since I mentioned the other snip was the old method but mainly because it's much better and more efficient. It only uses one image rather than however many you need for all the frames and we don't have to grab them manually and make our own timer.

This does exactly the same thing as my previous code snip:


Login to post a reply

Server time is: 2026-07-10 22:55:12
Your offset time is: 2026-07-10 22:55:12