Jump to content

Newbie - Background image


drula
 Share

Recommended Posts

Hi guys,

 

Today I want to try make some simple game with Phaser, but I stuck at the beginning. I can't set background image, also there is no tutorial or examples about basics.

I have a code like this:

 

http://jsbin.com/solerulu/5/edit

 

And I don't have any idea why it's not working. In firebug I see background.png is loaded but nothing happends. I see black rectangle only.

 

Could soimeone help me?

Link to comment
Share on other sites

Hi,

 

There are loads of examples (several hundred in fact) at http://examples.phaser.io and you'll find getting started tutorials as well.

 

However your code wouldn't run at all for me inside jsbin, the phaser.min.js file wouldn't load, nor would the image. After changing a load of paths to files that I know exist and aren't locked down under CORs it worked fine:

// main.jsvar game = new Phaser.Game(1000, 600, Phaser.CANVAS, 'game_div');var main_state = {    preload: function() {       game.load.image("background", "http://gametest.mobi/phaser095/assets/pics/aya_touhou_teng_soldier.png");            },    create: function() {       game.add.tileSprite(0, 0, 1000, 600, 'background');    },    update: function() {    }};game.state.add('main', main_state);  game.state.start('main');  
Link to comment
Share on other sites

  • 3 years later...
 Share

  • Recently Browsing   0 members

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