Jump to content

game.add.sprite() works, but game.add.image() does not


dsoodak
 Share

Recommended Posts

Windows 10, chrome and firefox, running on local WAMP server

from example http://phaser.io/examples/v2/sprites/add-an-image 

<script type="text/javascript">
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
function preload() {
    game.load.image('pic', 'assets/pics/acryl_bladerunner.png');
}
function create(){
    var image = game.add.sprite(100, 100, 'pic');//displays image with black background
    //var image = game.add.image(100, 100, 'pic');//just black background (this version used in example code)
}
</script>

 

Link to comment
Share on other sites

Phaser  2.4.6

Your code works on the on-line engine, but not when I run it on my local machine.

As in my own example, changing "var sprite = game.add.image(0, 0, 'phaser');" to "var sprite = game.add.sprite(0, 0, 'phaser');" makes it work

Link to comment
Share on other sites

Hi, check this post:

 I had problem with Firefox when running game locally (or form local server). If Phaser can not find image then it displays small green square. If you get just black (no picture, no green square), then something is wrong and it may be the issue in linked post.

Link to comment
Share on other sites

11 hours ago, dsoodak said:

It looks like I'm just not very familiar with which features are included in which build.

included "phaser.js" instead of "phaser.min.js" and it worked fine.

I assure you this isn't the problem. Image and Sprite are both available in all builds. Internally they are next to identical as well. There's no way one would render and the other doesn't in such a simple piece of code. Something else is going on, almost certainly local to your browser / set-up. Cache issue, image load issue, web server issue, etc. But it's not the code itself I'm afraid, that's a red herring in this instance.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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