Crafty.diamondIso

Place entities in a 45deg diamond isometric fashion. It is similar to isometric but has another grid locations In this mode, the x axis and y axis are aligned to the edges of tiles with x increasing being down and to the right and y being down and to the left.

Methods

Back to top

Crafty.diamondIso.init()

public this Crafty.diamondIso.init(Number tileWidth,Number tileHeight,Number mapWidth,Number mapHeight)
tileWidth

The size of base tile width's grid space in Pixel

tileHeight

The size of base tile height grid space in Pixel

mapWidth

The width of whole map in Tiles

mapHeight

The height of whole map in Tiles

x

the x coordinate of the TOP corner of the 0,0 tile

y

the y coordinate of the TOP corner of the 0,0, tile

Method used to initialize the size of the isometric placement. Recommended to use a size alues in the power of 2 (128, 64 or 32). This makes it easy to calculate positions and implement zooming.

Example

var iso = Crafty.diamondIso.init(64,128,20,20);

See Also

Back to top

Crafty.diamondIso.place()

public this Crafty.diamondIso.place(Entity tile,Number x, Number y, Number layer)
x

The x position to place the tile

y

The y position to place the tile

layer

The z position to place the tile

tile

The entity that should be position in the isometric fashion

Use this method to place an entity in an isometric grid.

Example

var iso = Crafty.diamondIso.init(64,128,20,20);
isos.place(Crafty.e('2D, DOM, Color').color('red').attr({w:128, h:128}),1,1,2);

See Also