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

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.

Guest
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.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.