Jump to content

I need help with my game score. :)


WhiteSoul
 Share

Recommended Posts

Hello. :)

 

I'm creating my first game; in that game you have to dodge enemies that are falling from the upper part of the screen. (Something like "game & watch" games)

The score is going to update each second, so it will tell you the amount of time that you survived, but the problem is that I have no clue how should I do it...

 

Can someone help me?

Thank you so much in advance. :)

Link to comment
Share on other sites

No tienes un codigo que mostrar seria mas facil ayudarte. :lol:

 

(I'm going to talk in English so people can understand if you don't mind :) )

 

Yes, I can post the code here but it's quite messy because I'm a newbie:

var game = new Phaser.Game(300, 500, Phaser.AUTO, "div", { preload: preload, create: create, update: update });						var player;			var speed = 4;			var enemies;						function preload() {											game.load.spritesheet("player", "assets/Personaje.png", 32, 80);				game.load.image("background", "assets/fondo.png");				game.load.spritesheet("fire", "assets/enemigo.png", 31, 40);								} 			function create() {													game.physics.startSystem(Phaser.Physics.ARCADE);							game.add.sprite(0, 0, "background");				enemies = game.add.sprite(150, 50, "fire");				enemies.anchor.setTo(0.5, 0.5);				enemies.animations.add("movimientoFuego", [0, 1], 4, true);				enemies.play("movimientoFuego");				var text = game.add.text(1, 20, "Score: ", { font: "18px Arial", fill: "#3B6CCD" });				player = game.add.sprite(150, 450, "player");				player.anchor.setTo(0.5, 0.5);			        player.animations.add("movimiento", [0, 1], 4, true);				player.play("movimiento");							game.physics.enable(player, Phaser.Physics.ARCADE);								player.body.collideWorldBounds = true;						} 			function update() {							if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {									player.x += velocidad;									}				else if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {									player.x -= velocidad;								}						}

I hope that this helps to solve the problem.

Anyways thank you so much. :D

Link to comment
Share on other sites

Well, more or less I managed myself to create a basic counter that it counts, but the problem now is that the score is running so fast. :lol:

 

I have created a new variable for the counter and then I added this part to the update function:

counter++;text.text = "Score: " + counter;
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...