tanmoy749

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 () {

    this.sprite1;
    this.sprite2;

    this.pad;

    this.stick1;
    

    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.physics.startSystem(Phaser.Physics.ARCADE);

    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('bg','http://examples.phaser.io/assets/sprites/platform.png');
        this.load.image('ship','elbo.svg');
        this.load.image('eye', 'elbo.svg');
        this.load.image('rotate', 'elbo.svg');
        this.load.image('sample', 'elbo.svg');
        this.load.image('add','elbo.svg');
        this.load.image('delete','http://examples.phaser.io/assets/sprites/space-baddie.png');
        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');

boat.anchor.setTo(0.5);

}

 

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.