phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
36.94k stars 7.08k forks source link

Uncaught TypeError: Cannot set property 'x' of undefined #1242

Closed chand1012 closed 9 years ago

chand1012 commented 9 years ago

I new to Phaser and I am trying to create a basic breakout style game but the ball won't move. In the console I am given the error "Uncaught TypeError: Cannot set property 'x' of undefined". The code it says is wrong is this: //add velocity this.ball.velocity.x = 200; this.ball.velocity.y = 200; please help

photonstorm commented 9 years ago

Sprites don't have a velocity property. Have a look at the code under the Arcade Physics section here: http://examples.phaser.io/