Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by LadyEmrys

Hi!

I've been trying to create a super simple kids game where the character doesn't really die, but am having lots of trouble getting the game over screen to load. I bought Jesse Freeman's book but wasn't able to get the game over code to work at all, even when i put a kill entity at the end that "should" trigger the game over screen. i'm super new to game programming, so kindly forgive my ignorance!

I have in my main.js:

MyGame = ig.Game.extend({

font: new ig.Font( 'media/04b03.font.png' ),
gravity: 400,
lives: 1,

and have tried to put in a game over function:

gameOver: function(){
ig.system.setGame(GameOverScreen);

In my player entity:

kill: function(){


this.parent();

},
onDeath: function(){
ig.game.lives --;
if(ig.game.lives < 0){
ig.game.gameOver();
//this.parent();
}},

but it doesn't do anything. Does anyone have any ideas on how i could make this work? Thanks so very much!
LE

1 decade ago by alexandre

When is onDeath supposed to be called? Try changing your player code for kill to this:

kill: function()
{
  this.parent();
  ig.game.lives--;
  if (ig.game.lives == 0)
    ig.game.gameOver();
},

1 decade ago by LadyEmrys

I figured out what i was missing! It was a typo in one line in my player kill function. Thanks so much!
Page 1 of 1
« first « previous next › last »