Skip to content

Commit 341ac49

Browse files
committed
Readme: fix the haxelib git command and use syntax highlighting
1 parent a5a8131 commit 341ac49

File tree

1 file changed

+44
-40
lines changed

1 file changed

+44
-40
lines changed

README.md

+44-40
Original file line numberDiff line numberDiff line change
@@ -17,61 +17,65 @@ Please note that this package depends on openfl-tiled.
1717

1818
To install the current development version you just need to run this in your terminal:
1919

20-
haxelib git openfl-tiled-flixel git@github.com:kasoki/openfl-tiled-flixel.git dev
20+
haxelib git openfl-tiled-flixel https://github.com/kasoki/openfl-tiled-flixel dev
2121

2222
### Usage
2323

2424
You just need to use FlxTiledMap instead of TiledMap:
2525

26-
var map = FlxTiledMap.fromAssets("assets/map.tmx");
27-
28-
this.add(map); // FlxTiledMap is a FlxGroup
26+
```haxe
27+
var map = FlxTiledMap.fromAssets("assets/map.tmx");
28+
29+
this.add(map); // FlxTiledMap is a FlxGroup
30+
```
2931

3032
Each layer is a FlxGroup of FlxSprites (each tile is a FlxSprite) which are not active (which means that the update method is not called). If you want to make a layer active to use it e.g. for collision detection read the snippet below:
3133

32-
// TODO: add flixel import statements here
33-
import openfl.tiled.FlxTiledMap;
34-
import openfl.tiled.FlxLayer;
34+
```haxe
35+
// TODO: add flixel import statements here
36+
import openfl.tiled.FlxTiledMap;
37+
import openfl.tiled.FlxLayer;
3538
36-
class TiledTestState extends FlxState {
39+
class TiledTestState extends FlxState {
40+
41+
private var map:FlxTiledMap;
42+
private var sprite:FlxSprite;
43+
44+
// FlxLayer is a FlxGroup of tiles
45+
private var colliderLayer:FlxLayer;
46+
47+
public override function create():Void {
48+
super.create();
49+
50+
map = FlxTiledMap.fromAssets("assets/map/test.tmx");
3751
38-
private var map:FlxTiledMap;
39-
private var sprite:FlxSprite;
52+
sprite = new FlxSprite(30, 30);
53+
sprite.makeGraphic(32, 32, FlxColor.RED);
4054
41-
// FlxLayer is a FlxGroup of tiles
42-
private var colliderLayer:FlxLayer;
55+
sprite.acceleration.y = 200;
4356
44-
public override function create():Void {
45-
super.create();
46-
47-
map = FlxTiledMap.fromAssets("assets/map/test.tmx");
48-
49-
sprite = new FlxSprite(30, 30);
50-
sprite.makeGraphic(32, 32, FlxColor.RED);
51-
52-
sprite.acceleration.y = 200;
53-
54-
// get the layer named "collider"
55-
colliderLayer = map.getLayerByName("collider");
56-
57-
// set the layer to active (update method will be called -> collision detection will be enabled)
58-
colliderLayer.setActive(true);
59-
60-
this.add(map);
61-
this.add(sprite);
62-
}
57+
// get the layer named "collider"
58+
colliderLayer = map.getLayerByName("collider");
6359
64-
public override function destroy():Void {
65-
super.destroy();
66-
}
60+
// set the layer to active (update method will be called -> collision detection will be enabled)
61+
colliderLayer.setActive(true);
62+
63+
this.add(map);
64+
this.add(sprite);
65+
}
66+
67+
public override function destroy():Void {
68+
super.destroy();
69+
}
70+
71+
public override function update():Void {
72+
super.update();
6773
68-
public override function update():Void {
69-
super.update();
70-
71-
FlxG.collide(sprite, colliderLayer);
72-
}
74+
FlxG.collide(sprite, colliderLayer);
7375
}
76+
}
77+
```
7478

7579
### Licence
7680

77-
openfl-tiled-flixel is licenced under the terms of the MIT licence.
81+
openfl-tiled-flixel is licenced under the terms of the MIT licence.

0 commit comments

Comments
 (0)