Glow Bunny
Glow Bunny

Reputation: 102

CreateJs not showing an image

I am new to create js and I want to show an image in localhost:8000

This is the index.html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Movement Test</title>
        <script src="https://code.createjs.com/1.0.0/createjs.min.js"></script>
        <script src="game.js"></script>
    </head>
    <body onload="init()">
        <canvas id="gameCanvas" width="640" height="480" style="display: block; margin: 0 auto;"></canvas>
    </body>
</html>

And this is the game.js

function init() {
    var stage = new createjs.StageGL("gameCanvas")

    var image = new createjs.Bitmap("dababyconvertible.jpg")
    stage.addChild(image)
}

Upvotes: 0

Views: 230

Answers (2)

Lanny
Lanny

Reputation: 11294

As @Cecherz mentioned, you have to ensure you update the stage. However, there is also likely a short delay while the image loads. On localhost it can be a few milliseconds, but in a real environment, it can be much longer.

Check out this answer that provides some good options: easeljs not showing bitmap

Upvotes: 0

Cecherz
Cecherz

Reputation: 56

Maybe check here: LINK

You should use stage.update() and something else :)

Upvotes: 0

Related Questions