Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


[JAVA]Explosion animation problem


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   -  Reputation: 120

Like
0Likes
Like

Posted 22 July 2011 - 07:41 PM

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

Sponsor:

#22 Servant of the Lord   Crossbones+   -  Reputation: 20384

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' 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] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#23 Rakso   Members   -  Reputation: 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.



PARTNERS