Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

[JAVA]Explosion animation problem

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
22 replies to this topic

#21 Rakso   Members   

120
Like
0Likes
Like

Posted 22 July 2011 - 07:41 PM

Alright thanks.. But where will i need the timeOfDeath ??

#22 Servant of the Lord   Members   

33692
Like
1Likes
Like

Posted 22 July 2011 - 07:43 PM

That code shouldn't be in a 'collision response' function. It should be in a 'update' or 'tick' function that runs every frame.

This goes is in your collision response function:
	public void collisionResponse(Entity exe){
		health = health - 50;
		if(health <= 0){
			isDead = true;
         	timeOfDeath = System.currentTimeMillis();
	}
}


And this goes in your 'called every frame' function.
public void update()
{
			if(isDead){
            	currentTime = System.currentTimeMillis();
            	amountOfTimePassedSinceDeath  = ( (currentTime - timeOfDeath)); 

            	if(amountOfTimePassedSinceDeath > 2500)
            		deathAnimationDone = true;
            	else if(amountOfTimePassedSinceDeath > 2000)
                	setGraphic(explosion5);    	
            	else if(amountOfTimePassedSinceDeath > 1500) 	
                	setGraphic(explosion4);
            	else if(amountOfTimePassedSinceDeath > 1000) 	
                	setGraphic(explosion3); 
            	else if(amountOfTimePassedSinceDeath > 500)  
            		setGraphic(explosion2); 
            	else
            		setGraphic(explosion);

			}
			
			if(deathAnimationDone){
				this.destroy();
			}
		}
	}

It's perfectly fine to abbreviate my username to 'Servant' or 'SotL' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal | [Fly with me on Twitter]

#23 Rakso   Members   

120
Like
1Likes
Like

Posted 22 July 2011 - 07:52 PM

Oh man!! It realy works now.. Thanks dude!! Thousand thanks! Just gona edit the time now so it looks better :D

Thanks again.. You saved my day, I will now try remember this and try do the same thing but in different ways so i learn from it.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.