Sign in to follow this  

Enable physics on sprite

Recommended Posts

Im working on simple platformer game and the piece of code below, I cannot activate physics to let walk my player with
whereever I put this, the error called Cannot read property 'enable' of null or Cannot read property 'arcade' of null appears
What exactly I need do to avoid this problem, thank you.

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', {
  preload: preload,
  create: create,
  update: update },
  false, true, {
        gravity:{ y: 200}


function preload () {'stone' , "stone.png");'player', "Player/player_tilesheet.png", 80, 110,);


var player;
var controls = {};
var playerSpeed = 250;

function create () { = 0x4888cc;
    this.player = game.add.sprite(360, 480 ,'player');
    this.player.animations.add('walk', [9,10],5,true);'walk');  
     controls = {
    	right: this.input.keyboard.addKey(Phaser.Keyboard.D),
    	left: this.input.keyboard.addKey(Phaser.Keyboard.A)


function update () {

		this.playerSpeed += playerSpeed;

    this.playerSpeed -= playerSpeed;





Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.