Jump to content

Physics Help


Mattward
 Share

Recommended Posts

This looks suspiciously like code that was posted here recently, to which I had to say the exact same thing:

 

You cannot physics enable JavaScript objects:

var player ={        Xpos: 0,        Ypos: platform1.Ypos - 48,        IsAlive: true,        score: 0}game.physics.enable(player, Phaser.Physics.ARCADE);

This is wrong. You can only enable physics on Sprites. That code above is not a sprite. So none of the physics operations from that point on will work.

 

There are hundreds of examples on the Phaser site you can look at - try some of the really simple Arcade Physics ones and look at the code carefully and you'll see how it's supposed to be done.

 

Also, as I mentioned last time, the update function is completely the wrong place to be doing things like creating Key objects or drawing the level. Update is called 60 times every single second - and the contents of that function should be kept to an absolute bare minimum. It's definitely not the place to be doing stuff like gameDraw or making keys.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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