Mattward Posted July 31, 2015 Share Posted July 31, 2015 Hi,I am making a game with a friend, but our Physics System won't work. We know it's because it can't get past line 215 as it gives us the Error: "Uncaught TypeError: Cannot read property 'velocity' of undefined" Here is the code:http://pastebin.com/q5cWJmK6 Thanks in advance! Link to comment Share on other sites More sharing options...
rich Posted July 31, 2015 Share Posted July 31, 2015 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. Pooya72 1 Link to comment Share on other sites More sharing options...
Recommended Posts