WhiteSoul Posted July 23, 2014 Share Posted July 23, 2014 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 More sharing options...
JP91 Posted July 23, 2014 Share Posted July 23, 2014 No tienes un codigo que mostrar seria mas facil ayudarte. Link to comment Share on other sites More sharing options...
WhiteSoul Posted July 23, 2014 Author Share Posted July 23, 2014 No tienes un codigo que mostrar seria mas facil ayudarte. (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. Link to comment Share on other sites More sharing options...
WhiteSoul Posted July 23, 2014 Author Share Posted July 23, 2014 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. 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 More sharing options...
Dumtard Posted July 23, 2014 Share Posted July 23, 2014 Something like this is what I believe you are looking for:http://examples.phaser.io/_site/view_full.html?d=time&f=custom+timer.js&t=custom%20timer Just set the timer to 1000 and add how ever many points the score you want. WhiteSoul 1 Link to comment Share on other sites More sharing options...
WhiteSoul Posted July 23, 2014 Author Share Posted July 23, 2014 Wooow yes, thank you so much!!! I didn't saw that before at the examples page. Next time I will pay more attention. ^^ Regards, Daniel. Link to comment Share on other sites More sharing options...
Recommended Posts