Jump to content

Beginner Sprite Issue


honkydory
 Share

Recommended Posts

I used Flixel for a while, and got quite comfortable with that framework, and just switched over to Phaser, but I'm having a little trouble getting off the ground.

 

I'm using Jesse Freeman's Phaser Project Template, and his 'Hello World' test builds fine, but when I try to use it for my own game, I can't seem to display Sprites properly, and I get a small white box in the location that the Sprite should be.

 

Here's my game class:

/// <reference path="../lib/Phaser/Game.ts" />(function () {        var myGame = new Phaser.Game(this, 'game', 1024, 768, init, create);        function init() {                myGame.loader.addImageFile('Stars', '/assets/Stars.png');        myGame.loader.load();    }var Stars: Phaser.Sprite;    function create() {           Stars = myGame.createSprite(0,0, 'Stars');        }})();

I am still working out of the original template folder, and my assets folder is within that, on the same level as my src folder. I've tried moving the folder around, changing the reference to it, but it seems like the images are never recognized. I'm getting no errors whether the folder is where I point to, or in the trash, which leads me to believe I'm doing something wrong.

 

Template Folder: - assets

                            - src

                            -deploy etc...

 

I'm sure I'm missing something really simple here, but I just can't see it.

 

Thanks.

 

Using Sublime 2 as editor, compiling via Terminal on a Mac OS X 10.6

Link to comment
Share on other sites

The assets path is relative. If you get a small white box it means it was unable to load the graphic. From your folder set-up I assume you need to remove the / at the start of /assets/Stars.png but it's hard to know for sure without seeing your web server set-up.

Link to comment
Share on other sites

Well, I tried a few things, with and without the slash before assets, re-installing Grunt, moving my folders around and switching browsers, and it seems to be a browser issue.

The same code, with assets in the same place works flawlessly with Chrome, but for whatever reason I was testing in Firefox 21, where it doesn't seem to load the images.

Thanks for the quick reply, and now that it's up and running, I'm really starting to dig Phaser!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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