Gamma Posted March 10, 2014 Share Posted March 10, 2014 Hello again everyone. I'm having trouble with trying to look at my characters collision box. I was looking at this example and I implemented the offset collision to my character, the problem is viewing how it looks like just like in the example. I am currently using the basic template provided on Github, and it doesn't seem to incorporate a render function. I tried to add one, but I kept getting errors. Link to comment Share on other sites More sharing options...
ctmartinez1992 Posted March 11, 2014 Share Posted March 11, 2014 It would be of immense worth for you to post your code, otherwise we have nothing to work with aside speculation Link to comment Share on other sites More sharing options...
Gamma Posted March 12, 2014 Author Share Posted March 12, 2014 I'm not sure if the template comes with a render function, but I placed the code down below in my create function: this.game.debug.renderBodyInfo(player, 150, 150); this.game.debug.renderPhysicsBody(player.body);Then I got this error(screenshot): Link to comment Share on other sites More sharing options...
xdiepx Posted March 12, 2014 Share Posted March 12, 2014 Are you doing this in the Game.js file? if so add this. BasicGame.Game = function (game) { //add this this.game = game; } Link to comment Share on other sites More sharing options...
Gamma Posted March 12, 2014 Author Share Posted March 12, 2014 Yes I have:basicGame.Game = function(game) { // When a State is added to Phaser it automatically has the following properties set on it, even if they already exist: this.game; // a reference to the currently running game this.add; // used to add sprites, text, groups, etc this.camera; // a reference to the game camera this.cache; // the game cache this.input; // the global input manager (you can access this.input.keyboard, this.input.mouse, as well from it) this.load; // for preloading assets this.math; // lots of useful common math operations this.sound; // the sound manager - add a sound, play one, set-up markers, etc this.stage; // the game stage this.time; // the clock this.tweens; // the tween manager this.world; // the game world this.particles; // the particle manager this.physics; // the physics manager this.rnd; // the repeatable random number generator // You can use any of these from any function within this State. // But do consider them as being 'reserved words', i.e. don't create a property for your own game called "world" or you'll over-write the world reference.};Also, may I note that my index.html file does not have "render" in it at all: window.onload = function() { // Create your Phaser game and inject it into the gameContainer div. // We did it in a window.onload event, but you can do it anywhere (requireJS load, anonymous function, jQuery dom ready, - whatever floats your boat) var game = new Phaser.Game(800, 600, Phaser.AUTO, 'gameContainer'); // Add the States your game has. // You don't have to do this in the html, it could be done in your Boot state too, but for simplicity I'll keep it here. game.state.add('Boot', BasicGame.Boot); game.state.add('Preloader', BasicGame.Preloader); game.state.add('MainMenu', BasicGame.MainMenu); game.state.add('Game', BasicGame.Game); // Now start the Boot state. game.state.start('Boot');};There doesn't seem to be a render function or "this.debug" in the template. How do I implement one? I noticed in tutorials that people implement this line of code, and when they call a render or debug method it would pop up seamlessly:var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render:render }); Thank you both for sticking around to help. Please feel free to assist me with this problem, I will also make an effort to fix this up myself as well. Link to comment Share on other sites More sharing options...
xdiepx Posted March 13, 2014 Share Posted March 13, 2014 basicGame.Game = function(game) { //>>>>>>>>>>>>>>>>>>>>> like this.this.game = game; // a reference to the currently running game}; then in render render: function(){ this.game.debug.renderPhysicsBody(player.body);} Link to comment Share on other sites More sharing options...
Gamma Posted March 14, 2014 Author Share Posted March 14, 2014 I had forgotten to add that part. I have now implemented it, and I received this error: Render Function:render: function(){ this.game.debug.renderBodyInfo(player, 150, 150); this.game.debug.renderPhysicsBody(player.body);} Link to comment Share on other sites More sharing options...
xdiepx Posted March 14, 2014 Share Posted March 14, 2014 Try updating to phaser v1.1.6 and then try it on IE 9+ or safari. for some reason the "this.game.debug.renderPhysicsBody(player.body);" only works on IE and safari and not in chrome or firefox for me. Link to comment Share on other sites More sharing options...
Gamma Posted March 15, 2014 Author Share Posted March 15, 2014 Try updating to phaser v1.1.6 and then try it on IE 9+ or safari. for some reason the "this.game.debug.renderPhysicsBody(player.body);" only works on IE and safari and not in chrome or firefox for me. I'll look into updating to the new version soon. Thank you for your help xdiepx. I appreciate it. And yes I have been using Chrome this whole time. Link to comment Share on other sites More sharing options...
pain_gwar Posted March 15, 2014 Share Posted March 15, 2014 If you update to Phaser 2.0 you have to use this in your render function: this.game.debug.body(player); lukaMis and Gamma 2 Link to comment Share on other sites More sharing options...
Recommended Posts