Jump to content

States + Physics Broken


Boxtufty
 Share

Recommended Posts

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.ohmygodplsmakeitstop

var 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

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 function
this.game.physics.collide(this.bird, this.cat);
 
Dropbox for sanity check:
 
 
 
 
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

 Share

  • Recently Browsing   0 members

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