Loading assets

Recommended Posts

How to load images or assets from local address instead of phaser assets through web?

Whenever I try to load assets from my local drive it doesn't show the contents.I want to load my assets offline.

Thanks in advance.

Share this post

Link to post
Share on other sites

Try adding a image the center of the game using the game centerX,centerY property.

if you are using group add it on the top most layer it should be visible clearly.

if there is a black box with green line instead of the image, that means the image is not loaded properly and check console for more


Share this post

Link to post
Share on other sites
var game = new Phaser.Game(800, 600, Phaser.CANVAS);
var PhaserGame = function () {




    var dropZone;
    var dragPosition;
    var bullet;
    var addGroup;
    var createBoat;
    var button;
    var buttons;
    var actionOnClick;
    var items;

  PhaserGame.prototype = {

    init: function () {
    this.game.renderer.renderSession.roundPixels = true;

    this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
    this.scale.pageAlignHorizontally = true;
    this.scale.pageAlignVertically = true;

    preload: function(){

        this.game.load.crossOrigin = 'anonymous'; 
      //  this.game.load.baseURL = 'http://examples.phaser.io/assets/';

        this.load.atlas('arcade', 'http://examples.phaser.io/assets/virtualjoystick/skins/generic-joystick.png', 'http://examples.phaser.io/assets/virtualjoystick/skins/generic-joystick.json');
      	this.load.image('boat', 'bubble.png');
        this.load.image('background', 'http://examples.phaser.io/assets/sprites/platform.png');
        this.load.image('eye', 'elbo.svg');
        this.load.image('rotate', 'elbo.svg');
        this.load.image('sample', 'elbo.svg');
        this.load.spritesheet('item', 'http://examples.phaser.io/assets/buttons/number-buttons-90x90.png', 90, 90);
     //   this.load.spritesheet('butt', 'http://examples.phaser.io/assets/buttons/button_sprite_sheet.png', 193, 71);



Share this post

Link to post
Share on other sites

Make sure you provide the correct file name,

this.load.image('boat',' 'assets/bubble.png ')'

Also, I can not see your create method. Is it similar to this?

create: function(){

var boat = this.add.sprite(game.width/2,game.height/2,'boat');




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.

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.


  • Recently Browsing   0 members

    No registered users viewing this page.