Boxtufty Posted April 7, 2014 Share Posted April 7, 2014 In the code below, the collision check works fine but when I try to use the commented out lines, my game doesn't load. I've tried a bunch of stuff but this.nope.ohmygodplsmakeitstopvar game = new Phaser.Game(400, 490, Phaser.AUTO, '');var main_state = {preload: function() { this.game.load.image('bird', 'assets/bird.png'); this.game.load.image('cat', 'assets/catyo.png'); },create: function() { this.bird = this.game.add.sprite(100, 245, 'bird'); this.cat = this.game.add.sprite(300, 245, 'cat');},update: function() { this.game.physics.collide(this.bird, this.cat); //this.cat.rotation = this.game.physics.arcade.angleBetween(this.cat, this.bird); //this.game.physics.arcade.moveToObject(this.cat,this.bird);}};game.state.add('main', main_state); game.state.start('main'); Link to comment Share on other sites More sharing options...
Manifest Posted April 7, 2014 Share Posted April 7, 2014 As per point 2 in this topic 2) Using a modified State update core loop. The State.update method is now called BEFORE any other sub-system I suspect cat doesn't exist when you try to update it. Can you provide any error messages? Link to comment Share on other sites More sharing options...
rich Posted April 8, 2014 Share Posted April 8, 2014 What's the actual error if you use either of those commented-out calls? They both look valid on the surface. Link to comment Share on other sites More sharing options...
Boxtufty Posted April 8, 2014 Author Share Posted April 8, 2014 Thanks for your replies, I'd really like to get back to making something soon ;_; Turns out I was using phaser ~1.1.5. Whoops. Now trying with phaser 2.0.2 and I'm having basically the same issue. Physics + States = nope. Even collide is dead now. The error in firebug is:TypeError: this.game.physics.collide is not a functionthis.game.physics.collide(this.bird, this.cat); Dropbox for sanity check:https://www.dropbox.com/sh/pnq4jl1yt15gi8r/WCDMUG3mcC Uncomment any of them and it dies. It's such a simple example I don't understand what I could be screwing up <!doctype html> <html lang="en"> <head> <script type="text/javascript" src="phaser.min.js"></script> </head><body><script type="text/javascript">var game = new Phaser.Game(600, 600, Phaser.AUTO, ''); var main_state = {preload: function() { this.game.load.image('bird', 'assets/bird.png'); this.game.load.image('cat', 'assets/cat.png'); }, create: function() { this.bird = this.game.add.sprite(100, 245, 'bird'); this.cat = this.game.add.sprite(300, 245, 'cat');}, update: function() { //this.game.physics.collide(this.bird, this.cat); //this.cat.rotation = this.game.physics.arcade.angleBetween(this.cat, this.bird); //this.game.physics.arcade.moveToObject(this.cat,this.bird);}};game.state.add('main', main_state); game.state.start('main'); </script></body></html> Link to comment Share on other sites More sharing options...
rich Posted April 9, 2014 Share Posted April 9, 2014 Please look at the Arcade Physics examples at http://examples.phaser.io and copy carefully the approach used in those. You'll see they enable calls to start Arcade Physics running, enable a sprite body and then collide is now found on this.game.physics. arcade.collide, all of which are missing from the example above Link to comment Share on other sites More sharing options...
Recommended Posts