drula

Newbie - Background image

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?

Share this post


Link to post
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');  

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.