Jump to content

Loading assets


tanmoy749
 Share

Recommended Posts

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

 

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


    },

 

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

}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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