Jump to content

how to create a method for a shooter game


Recommended Posts

I am learning to use this engine, but compared to some methods I've seen online, for example Phaser.js. not managed to create a method that can make my player shoot.


This is my class and my method.


game.createClass('Shoot', {

init: function(x, y){

this.disparo = new game.Sprite('shoot.png');


this.bodyDisparo = new game.Body({


x: x + this.disparo.width,






var circulo = new game.Rectangle(this.disparo.width, this.disparo.height);







shot: function(){

this.bodyDisparo.velocity.x = 260;



update: function() {

this.disparo.position.x = this.bodyDisparo.position.x;

this.disparo.position.y = this.bodyDisparo.position.y;




Not if well implemented this code I wrote.


I'm learning to program games in html5.

Link to comment
Share on other sites

No, I get no error in my code on console.
The problem is that the bullet appears on the scene, ok when I press the "Z" key is assigned, it moves to the desired speed in the x axis. but only one bullet fired, not many as would be normal.
watch this code in phaser.
timeShoot = 0;
function shootHeroe () {
      if (game.time.now > timeShoot){
          var local = municion.getFirstExists(false);
          if (local){
              local.reset(player.x, player.y + 20);
              local.body.velocity.y = -400;
              timeShoot = game.time.now + 600;
game.time.now = current time, this in panda.js is "game.system.delta"
This is the explanation of the creator of the blog:
"If you remember the post recycling groups have the method .getFirstExists (false); with which we recover the children of the group with the property exists to false, as explained at the beginning the method .createMultiple () creates objects with this property to false."
This is the blog post is in Spanish. so I'm trying to translate you what it says.  http://goo.gl/8RVksJ
the result in phaser. http://goo.gl/BuH3x0  .....  press key "SPACE" for firing.
I want you communicate if you translate this post. to see if we can also make an example or tutorial and post it here on the forum and it will help other people who want to make a game of this category (shooter). since in the demos and other information not find something similar.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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