Jump to content

User should change her own background image


Recommended Posts



I work at a small game - at this can user choose your own background image.


I have any problems to change the backgound image after the game start.


my dev site http://www.zwischenstation-mobile.de/spiel.html


I set a global var game and initalisize the game

var game;window.onload = function() {...game = new Phaser.Game(320,480,Phaser.CANVAS,"playground",{preload:onPreload, create:onCreate, update:onUpdate}, true);...}

after this, I´ll update the background with

(function($) {  $( window ).load(function() {	game.load.image("background", "/files/springende-punkt/content/games/gyro-sp/koala.jpg");	game.add.tileSprite(0, 0, 320, 480, 'background');  });})(jQuery);

as test but the goal is to load a local file with

<input name="picOneUpload" type="file" accept="image/*">

Have anybody a idea?!?

Link to comment
Share on other sites

I used this solution




and works fine BUT the new sprite is loaded at top - I just try to set background image at bottom

	   var bgLayer = game.add.group();	   bgLayer.z = 0;	   var bg = game.add.tileSprite(0, 0, 1024, 768, 'background');	   bgLayer.add(bg);

or set my "player" on top

    // Create the player layer    var playerLayer = game.add.group();    playerLayer.z = 10;    // adding the player on stage    player = game.add.sprite(160,240,"player");

hmm.... don´t works


at this time, I have a second canvas behind the phaser canvas als "background"

Link to comment
Share on other sites


  • Recently Browsing   0 members

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