saschagehlich/ldfw — pull request #1 by K4stor (2013-12-10 14:26:43+00:00)
Title: added tile map class + refactoring for require

Added a tilmap class that handled json files exported by "Tiled"
It is able to render layers parallax

Here is an example for an actor that makes use of the tilemap class

class TileMapActor extends LDFW.Actor
constructor: (game, @tileMapName, @tileSetName) ->
super

image = new Image()
image.onload = =>
data = game.preloader.get @tileMapName
image = game.preloader.get @tileSetName

@tileMap = new LDFW.TileMap game, data, image
@counter = 0
@scrollX = 0
@scrollY = 0

update: (delta) ->
@counter++
if @counter > 2
@counter = 0
@scrollY++
@scrollX++
@tileMap?.setScrollX(0, @scrollX)
@tileMap?.setScrollY(0, @scrollY)
@tileMap?.setScrollX(1, @scrollX * 2)
@tileMap?.setScrollY(1, @scrollY * 2)

draw: (context) ->
@tileMap?.draw context

module.exports = TileMapActor