0

I'm trying to generate a map from a json file and i'm using the framework EaseIJS.

Actually, i have a json like this :

[
        [ 1, 1, 0, 0, 0 ],
        [ 0, 0, 0, 0, 0 ],
        [ 0, 0, 1, 0, 1 ],
        [ 0, 0, 1, 0, 0 ],
        [ 0, 0, 0, 0, 1 ]
]

And for each number (tile), i can generate a color :

var tiles =
{
        0: function(){return new Tile ( TileType.DRAW, gfx.solTAlea(200,200,128), true );},
        1:null
};

In this example, with the function solTAlea(), i generate a tile with a random color :

$color = Graphics.getRGB ( $r, $g, $b );
this.gfx = new Shape();
this.gfx.name = $color;
this.gfx.graphics.beginFill($color)
                  .moveTo(64,0)
                  .lineTo(0,-32)
                  .lineTo(-64,0)
                  .lineTo(0,32)
                  .lineTo(64,0)
                  .closePath();
return this.gfx;

The value of this return is my tile,with a specific color. After that i can draw it on my canva map.

But how can i create an image from a file ? I don't need to generate a random color tile ($color = Graphics.getRGB ( $r, $g, $b );) but i need to create a tile with an image, png for example..

Do you have any ideas ? For this example i use the function Shape() tu create the tile.

Thanks !

4

1 回答 1

2

您好,您可以简单地使用 Bitmap 类:

 var image = new createjs.Bitmap("image.png");
于 2013-06-09T17:41:49.290 回答