Jump to content

Sprite not rendering well


Zeephaser
 Share

Recommended Posts

Hey guys I'm new to phaser and I'm testing it out with a simple example, I've run into a problem where my sprites are rendered as black boxes it doesn't matter what sprite I load they all come out as boxes. I don't understand what's happening please help me. Here's my code :

var game=new Phaser.Game(900,800,Phaser.AUTO,"gamediv");

var mainstate={

preload:function(){

game.load.image("circle","circle.png");

game.stage.backgroundColor="00feff";

},

create:function(){

game.physics.startSystem(Phaser.Physics.ARCADE);

this.hellosprite=game.add.sprite(20,300,"circle");

game.physics.arcade.enable(this.hellosprite);

this.hellosprite.body.gravity.y=1000;

this.hellosprite.body.collideWorldBounds=true;

this.hellosprite.body.bounce.y=0.6;

this.cursors.game.input.createCursorKeys();

},

update:function(){

this.hellosprite.body.velocity.x+=1

if(this. hellosprite. body. velocity.x>=30) {

this. hellosprite. body. velocity. x=0;

}

}

};

game.state.add("main",mainstate);

game.state.start("main");

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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