Jump to content


  • Content Count

  • Joined

  • Last visited

About igkman

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I have a group of Enemy(name of my object) objects that I'm trying to call a certain function from the Enemy class. When I try to do so, nothing would happen. So I wrote in an alert to see if I could access one of the variables from the Enemy class and it told me that the variable was undefined. The code is in the createEnemy class of the Game class. I'm not sure if the Enemy class would be needed or not so I added it here just to be safe. Game class: Game = function(game) {} Phaser.GameObjectFactory.prototype.enemy = function(x,y,xPix,yPix,enemyNum) { return this.game.add.exist
  2. That's what it's suppose to do. I might be misinterpreting the function though
  3. enemies.getAt(this.cnt) is supposed to return a child of the group "enemies" at the index 'this.cnt'. cnt is an integer set at zero. does that help?
  4. How is that? The problem lies within the update function of the Game class.
  5. Game = function(game) { this.timer = 0; this.cycle = 1000; this.cnt = 0; } Phaser.GameObjectFactory.prototype.enemy = function(x,y,xPix,yPix,enemyNum) { return this.game.add.existing(new Enemy(this.game,x,y,xPix,yPix,enemyNum) ); } Game.prototype = { create: function() { game.physics.startSystem(Phaser.Physics.ARCADE); enemies = game.add.group(); enemies.enableBody = true; // locations for the first group of enemies to fly in var group1PixelLocations = { 'x' : [game.width/2,game.width/2-30,game.width/2,game.width/2-30, game.width/2,game.width/2-30,game.width/2,game.wid
  6. var group1PixelLocations = { 'x' : [game.width/2,game.width/2-30,game.width/2,game.width/2-30,game.width/2,game.width/2-30], 'y' : [(game.height/2)-30,(game.height/2)-60,(game.height/2)-90,(game.height/2)-120,(game.height/2)-150], }; //create enemies for (var i = 0; i < 5; i++) { enemies.create(game.add.enemy(game.width/1.33,0,group1PixelLocations.x[i],group1PixelLocations.y[i])); } The last two parameters of game.add.enemy() ,xPix and yPix, are undefined when I try to pass them unto my Enemy Class: var Enemy = function(game,x,y,xPix,yPix) { Phaser.Sprite.call(th
  7. Can you check my code again to see if I'm still overwriting anything? I'm now getting this error: 'Uncaught TypeError: Cannot read property 'animations' of null' for my enemy1 variable Which I think is odd. It is null at first, but that should change in the create function. Is it still being overwritten? var Enemy = function(game,x,y) { Phaser.Sprite.call(this,game,x,y,'playerKey'); this.enemy1 = null; this.pixel = null; this.x = x; this.y = y; this.tween = null; this.game = game; } Enemy.prototype = Object.create(Phaser.Sprite.prototype); Enemy.prototype.constr
  8. I'm still getting the error. This is the peice of code that adds the Enemy object to multiple groups in a create function: enemies = game.add.group(); enemies.classType = Enemy; enemies.enableBody = true; enemies.createMultiple(10).forEach( function(sprite) { sprite.x = 30; sprite.y = 300; },this); Here's my Enemy class: var Enemy = function(game,x,y) { Phaser.Sprite.call(this,game,x,y,'playerKey'); this.enemy1 = null; this.pixel = null; this.x = x; this.y = y; this.tween = null; this.game = game; } Enemy.prototype = Object.create(Phaser.Sprit
  9. I tried that with my own project and I got the following error: Uncaught TypeError: this.onTextureUpdate is not a function(…) Code: enemies.createMultiple(10).forEach( function(sprite) { sprite.game = game; sprite.x = 30; sprite.y = 300; });
  10. I would also like to know how I could set the parameters of the instances as well. function MyAwesomeSprite(game, x, y) { Phaser.Sprite.call(this, game, x, y, 'playerKey'); } // All that custom sprite class stuff... var myGroup = game.add.group(); myGroup.classType = MyAwesomeSprite; myGroup.createMultiple(20); // myGroup now has 20 instances of MyAwesomeSprite. I found this here, but I was confused as to how would one set the x and y parameters while creating 20 instances of said object?
  11. Isn't this snippet of code supposed to do that? bullet = game.add.weapon(2,'bullet');
  12. var player; var keys; var shootButton; var bullet; function create() { //game.add.sprite(0,0, 'background'); game.physics.startSystem(Phaser.Physics.ARCADE); //creates player player = game.add.sprite(0.45*600,600-50,'galaga'); game.physics.arcade.enable(player); // allows player to fire 2 bullets bullet = game.add.weapon(2,'bullet'); // when bullet leaves the screen, it will be destroyed bullet.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; // offset rotation bullet.bulletAngleOffset = 90; // prevents ship from auto firing bullet.autofire = false; // The spee
  • Create New...