Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

weapon.prototype problem


Recommended Posts


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 


what 's wrong ?


weapon = function(){

	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');


	//  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() {

var game_state = {
	create: function(){
		this.canon=new weapon()


Link to comment
Share on other sites


  • Recently Browsing   0 members

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