Zeephaser Posted July 2, 2015 Share Posted July 2, 2015 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"); Zeephaser 1 Link to comment Share on other sites More sharing options...
shakeshake Posted July 2, 2015 Share Posted July 2, 2015 Is the image in the correct folder - in your case the root folder? You can check your browsers console to see eventual network errors (developer tools in chrome or IE (F12), firebug in firefox...) Link to comment Share on other sites More sharing options...
Zeephaser Posted July 2, 2015 Author Share Posted July 2, 2015 Yeah they're all in the right folder I'm the root. I didn't make an assets folder so... Link to comment Share on other sites More sharing options...
shakeshake Posted July 2, 2015 Share Posted July 2, 2015 No errors in the console? For me this looks quite correct but it's hard to say without formating... Can you edit your post and mark the code as javascript code? Link to comment Share on other sites More sharing options...
Zeephaser Posted July 2, 2015 Author Share Posted July 2, 2015 Sorry how do I do that Link to comment Share on other sites More sharing options...
solegrina Posted July 2, 2015 Share Posted July 2, 2015 Opening/using the console with:Google ChromeFirefoxInternet Explorer Link to comment Share on other sites More sharing options...
Zeephaser Posted July 3, 2015 Author Share Posted July 3, 2015 thanks Link to comment Share on other sites More sharing options...
Zeephaser Posted July 6, 2015 Author Share Posted July 6, 2015 I found the mistake guys, I preloaded the images with assignment syntax, I forgot it was a method. game . load. image = xxxx; instead of game. load. image (xxxx) ; Link to comment Share on other sites More sharing options...
Recommended Posts