Jump to content

Image from atlas not getting displayed


kray
 Share

Recommended Posts

I have an atlas containing all letters. Due to some reason, the image chosen from the atlas is not being displayed. Instead, it just shows a black box.

My preloader:

 

 preload: function() {        this.load.spritesheet('dude', 'asset/dude.png', 32, 48);        this.load.atlas('alphavets','asset/letters.png','asset/letters.json');        this.load.image('ground','asset/platform.png');        this.load.image('sky','asset/sky.png');    }

Using the atlas:

 

var x = Math.floor(Math.random()*1000)%this.world.width;            var letter = this.add.sprite(x, 0, 'alphabets');            letter.frameName = "a.png";            this.physics.arcade.enable(letter);            console.log("Chosen: "+img);            letter.body.gravity.y = 200;

Why is this happening? The console also says phaser.js not found. I have copied phaser.min.js to my folder. 

 

post-13815-0-17994900-1428476216_thumb.p

Link to comment
Share on other sites

So, without seing your atlas file, I can already tell : 

 

- you are loading "alphavets" and using "alphabets"

- you are using spritename "a.png", check if it's this in your json or just "a" (some packers trim the file extension)

- for simplicity, you can do : this.add.sprite(posX, posY, "alphabets", "a.png") to avoid another line setting the initial frame name

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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