Jump to content

weapon.prototype problem


espace
 Share

Recommended Posts

hi, 

i'm searching to make a prototype with the weapon class but that don't work. i have this error :

phaser.min.js:6 Uncaught TypeError: a.parent.removeChild is not a function
    at c.World.b.DisplayObjectContainer.addChildAt (phaser.min.js:6)
    at c.World.b.DisplayObjectContainer.addChild (phaser.min.js:6)
    at c.World.c.Group.add (phaser.min.js:11)
    at c.GameObjectFactory.existing (phaser.min.js:14)
    at Object.create (main.js:322)
    at c.StateManager.loadComplete (phaser.min.js:10)
    at c.StateManager.preUpdate (phaser.min.js:10)
    at c.Game.updateLogic (phaser.min.js:12)
    at c.Game.update (phaser.min.js:12)
    at c.RequestAnimationFrame.updateRAF (phaser.min.js:18)

however i take this from these example 

https://phaser.io/examples/v2/weapon/asteroids

what 's wrong ?

Thanks.

weapon = function(){
	Phaser.Weapon.call(this,game,20,'rect')


	this.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS;

	//  Because our bullet is drawn facing up, we need to offset its rotation:
	this.bulletAngleOffset = 90;

	//  The speed at which the bullet is fired
	this.bulletSpeed = 400;

	//  Speed-up the rate of fire, allowing them to shoot 1 bullet every 60ms
	this.fireRate = 60;

	//  Add a variance to the bullet angle by +- this value
	this.bulletAngleVariance = 10;

	this.canon = game.add.sprite(320, 500, 'rect');

	game.physics.arcade.enable(this.canon);

	//  Tell the Weapon to track the 'player' Sprite, offset by 14px horizontally, 0 vertically
	this.trackSprite(this.canon, 14, 0);

}


weapon.prototype = Object.create(Phaser.Weapon.prototype)
weapon.prototype.constructor = weapon

weapon.prototype.update = function() {
this.fire()	
}

var game_state = {
	create: function(){
		game.physics.startSystem(Phaser.Physics.ARCADE)
		this.canon=new weapon()
		game.add.existing(this.canon)
	},
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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