Jump to content

debug doesn't seem to work?


WhipJr
 Share

Recommended Posts

I've recently been coding an infinite runner game in which the player is allowed to attack freely as they encounter obstacles and enemies. this being said, there is various objects that use collisions and physics bodies for collision detection and i have tried everything i have found to render the debug boxes to no avail.

 

Attack = function() {
       	    Phaser.Sprite.call(this, game, player.x + 15, player.y, 'Attack');
       	    game.add.existing(this);
       	    game.physics.enable(this, Phaser.Physics.ARCADE);
       	    this.animations.add('attack');
       	    this.animations.play('attack', 8, false, true);
            this.body.setSize(50, 80, 30, 0);
       	    this.body.allowGravity = false;
       	    this.body.immovable = true;
       	    game.time.events.add(Phaser.Timer.SECOND * attackSpeed, setAttack, this);
       	    curAtk = this;
       	};
       	//these set the variable 'Objects' 
       	Attack.prototype = Object.create(Phaser.Sprite.prototype);
       	Attack.prototype.constructor = Enemy;

       	//this checks conditions specific for the Attack Object made through the class every update.
       	Attack.prototype.update = function() {
       	    this.x = player.x + 15;
       	    this.y = player.y;
            this.game.debug.bodyInfo(this);
       	};

here is specifically the attacking object spawn which spawns the attack object, and on the last line of actual code i try to call the debug information to render.

I'm not sure that this is the way to do it, but i have added the "render: render" to my game initialization and tried to call the code in that as well plus using the references within the examples as well and i cannot for the life of me figure out why the body's are not debugging allowing me to fine tune the desired collision areas. Any thoughts or ideas are welcome. if more code is needed of what i have i can upload my JS files.

Also a quick note, there are no error messages. and everything runs as expected aside from the debugging aspect and proper hit-box areas.

Link to comment
Share on other sites

i did notice that, and after i changed it i receive this error:

Uncaught TypeError: Cannot read property 'body' of undefined
    at Attack.update (objectSpawn.js:111)
    at Phaser.World.Phaser.Group.update (phaser.js:32223)
    at Phaser.Stage.update (phaser.js:30324)
    at Phaser.Game.updateLogic (phaser.js:34917)
    at Phaser.Game.update (phaser.js:34859)
    at Phaser.RequestAnimationFrame.updateRAF (phaser.js:62567)
    at _onLoop (phaser.js:62550)
Attack.update @ objectSpawn.js:111
Phaser.Group.update @ phaser.js:32223
Phaser.Stage.update @ phaser.js:30324
updateLogic @ phaser.js:34917
update @ phaser.js:34859
updateRAF @ phaser.js:62567
_onLoop @ phaser.js:62550

the error is at the same line as before. i also changed the "(this)" to "(this.body)" to try and fix the error with no luck.

~EDIT~

okay so I've gotten the render to work for the player which is a constant object in the scene, but for my code above these objects are temporary. Is there any way to show the colliders of the objects spawned using my current spawning method?

 

im using this to show the body info for the player.

game.debug.body(player);

but from what i can tell this is only used for individual instances.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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