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 DBPro Corner / 2d Sprite Death Animation

Author
Message
Raptor King
16
Years of Service
User Offline
Joined: 3rd Mar 2008
Location:
Posted: 3rd Mar 2008 18:13
I'm new around here, and need some help on this...

In my spaceship game I made an animated UFO sprite, and a player sprite. I also got the player to shoot a weapon and everything. Yet when I would shoot the UFO, it would play a sound I loaded, delete the sprite, but not play the UFOs animation. And when I tried to play the animation in a loop, it worked just fine. How do I get it to die right!

Any help would be appreciated,
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd Mar 2008 20:43
It would be much easier to see the problem if you posted the part of your code that arises this problem

"I kören hörs de brummande busarna Björnligan och Gondolen"
Raptor King
16
Years of Service
User Offline
Joined: 3rd Mar 2008
Location:
Posted: 3rd Mar 2008 21:05
Here's the Code.
Sorry about not inserting this sooner, I was in a rush to post...



The ship .bmp was 64x64, the Alien 832x64, the proton 7x7
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 3rd Mar 2008 21:47
i might sound stupid but, why not try commenting out the line for "delete sprite.."

that should allow you to see if it plays?

dont forget a program cycle is very very rapid.

if you delete the sprite and its just about to play surely it wont be visible??

meh.
Good luck!
Paul

Paul
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd Mar 2008 22:31
I agree with Paul; if you delete the sprite there it won't get any time to play.

You could do something like this instead:


"I kören hörs de brummande busarna Björnligan och Gondolen"
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 3rd Mar 2008 22:39
this is definately something worth trying..

Its the same as doing something like:

psudo code:
in a cinema/theatre:

1.audience sits down

START LOOP

2.play movie/film/scene

3.delete/stop movie/film etc

REPEAT LOOP

4. audience all leave as the film is just starting with its first frame (20TH CENTURY FOX.. etc)
then its deleting itself.
then its playing first frame again.

FOREVER

argg!!

Paul
Raptor King
16
Years of Service
User Offline
Joined: 3rd Mar 2008
Location:
Posted: 3rd Mar 2008 23:50
I think I found out (maybe) the problem...

I did a couple test runs, and the code is working better than it was. It seems that now that it has something to do with the protons collision. Take a look at this revised code.



When the sprite moved slower, it played all the way through. The faster it moved, the less frames it played. It suggests that the sprite plays only if the collision is true. Should a timer based function be used for this?

Thanks for all the help.
Raptor King
16
Years of Service
User Offline
Joined: 3rd Mar 2008
Location:
Posted: 4th Mar 2008 15:41
Problem Solved. Here's the final code. When the proton hits the ship (regardless of speed) it plays the animation until the final frame is reached. Then it deletes the ship.


And again, thanks for all your help in getting me here.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 4th Mar 2008 17:04
Glad you solved it

"I kören hörs de brummande busarna Björnligan och Gondolen"
Paul08
16
Years of Service
User Offline
Joined: 20th Feb 2008
Location: Oxford, UK
Posted: 4th Mar 2008 19:30
but wont that only allow one proton/bullet at a time??

Paul

Login to post a reply

Server time is: 2024-09-27 12:16:28
Your offset time is: 2024-09-27 12:16:28