mirror of
https://github.com/photonstorm/phaser
synced 2024-11-11 07:34:43 +00:00
Fresh build. Added pre/post update hooks to Graphics.
This commit is contained in:
parent
d026f968de
commit
78bf874888
7 changed files with 1917 additions and 284 deletions
881
build/phaser.js
881
build/phaser.js
File diff suppressed because it is too large
Load diff
30
build/phaser.min.js
vendored
30
build/phaser.min.js
vendored
File diff suppressed because one or more lines are too long
906
examples/assets/tilemaps/maps/collision_test.json
Normal file
906
examples/assets/tilemaps/maps/collision_test.json
Normal file
|
@ -0,0 +1,906 @@
|
|||
{ "height":18,
|
||||
"layers":[
|
||||
{
|
||||
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0,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{
|
||||
"collides":"true"
|
||||
},
|
||||
"type":"tilelayer",
|
||||
"visible":true,
|
||||
"width":50,
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"height":18,
|
||||
"name":"collision",
|
||||
"objects":[
|
||||
{
|
||||
"height":0,
|
||||
"name":"",
|
||||
"polyline":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":224
|
||||
},
|
||||
{
|
||||
"x":-32,
|
||||
"y":224
|
||||
},
|
||||
{
|
||||
"x":-32,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":1568,
|
||||
"y":-32
|
||||
}],
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":32,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"name":"",
|
||||
"polyline":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":-64
|
||||
},
|
||||
{
|
||||
"x":128,
|
||||
"y":-64
|
||||
},
|
||||
{
|
||||
"x":128,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":160,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":160,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":64,
|
||||
"y":160
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"name":"",
|
||||
"polyline":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":64
|
||||
},
|
||||
{
|
||||
"x":256,
|
||||
"y":64
|
||||
},
|
||||
{
|
||||
"x":256,
|
||||
"y":96
|
||||
},
|
||||
{
|
||||
"x":352,
|
||||
"y":96
|
||||
},
|
||||
{
|
||||
"x":352,
|
||||
"y":64
|
||||
},
|
||||
{
|
||||
"x":256,
|
||||
"y":64
|
||||
},
|
||||
{
|
||||
"x":256,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":128,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":416,
|
||||
"y":96
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"name":"",
|
||||
"polyline":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":160,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":160,
|
||||
"y":64
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":64
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":224
|
||||
},
|
||||
{
|
||||
"x":960,
|
||||
"y":224
|
||||
},
|
||||
{
|
||||
"x":960,
|
||||
"y":160
|
||||
},
|
||||
{
|
||||
"x":992,
|
||||
"y":128
|
||||
},
|
||||
{
|
||||
"x":1024,
|
||||
"y":128
|
||||
},
|
||||
{
|
||||
"x":1024,
|
||||
"y":64
|
||||
},
|
||||
{
|
||||
"x":928,
|
||||
"y":64
|
||||
},
|
||||
{
|
||||
"x":896,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":896,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":928,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":960,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":992,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":992,
|
||||
"y":-128
|
||||
},
|
||||
{
|
||||
"x":1024,
|
||||
"y":-128
|
||||
},
|
||||
{
|
||||
"x":1024,
|
||||
"y":-160
|
||||
},
|
||||
{
|
||||
"x":1088,
|
||||
"y":-160
|
||||
},
|
||||
{
|
||||
"x":1088,
|
||||
"y":-128
|
||||
},
|
||||
{
|
||||
"x":1120,
|
||||
"y":-128
|
||||
},
|
||||
{
|
||||
"x":1120,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":1152,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":1184,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":1184,
|
||||
"y":-64
|
||||
},
|
||||
{
|
||||
"x":1216,
|
||||
"y":-64
|
||||
}],
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":0,
|
||||
"y":320
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"name":"",
|
||||
"polyline":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":64
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":64
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":96
|
||||
},
|
||||
{
|
||||
"x":-32,
|
||||
"y":128
|
||||
},
|
||||
{
|
||||
"x":-128,
|
||||
"y":128
|
||||
},
|
||||
{
|
||||
"x":-128,
|
||||
"y":192
|
||||
},
|
||||
{
|
||||
"x":-96,
|
||||
"y":192
|
||||
},
|
||||
{
|
||||
"x":-64,
|
||||
"y":224
|
||||
},
|
||||
{
|
||||
"x":-64,
|
||||
"y":288
|
||||
},
|
||||
{
|
||||
"x":320,
|
||||
"y":288
|
||||
}],
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":1216,
|
||||
"y":256
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"name":"",
|
||||
"polyline":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":-512
|
||||
},
|
||||
{
|
||||
"x":-256,
|
||||
"y":-512
|
||||
},
|
||||
{
|
||||
"x":-256,
|
||||
"y":-480
|
||||
},
|
||||
{
|
||||
"x":-352,
|
||||
"y":-480
|
||||
},
|
||||
{
|
||||
"x":-352,
|
||||
"y":-512
|
||||
},
|
||||
{
|
||||
"x":-1152,
|
||||
"y":-512
|
||||
}],
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":1536,
|
||||
"y":544
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"name":"",
|
||||
"polyline":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":-352,
|
||||
"y":0
|
||||
}],
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":384,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"name":"platform",
|
||||
"polyline":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":-64
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":-64
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":-96
|
||||
},
|
||||
{
|
||||
"x":128,
|
||||
"y":-96
|
||||
},
|
||||
{
|
||||
"x":160,
|
||||
"y":-128
|
||||
},
|
||||
{
|
||||
"x":192,
|
||||
"y":-128
|
||||
},
|
||||
{
|
||||
"x":192,
|
||||
"y":-96
|
||||
},
|
||||
{
|
||||
"x":160,
|
||||
"y":-64
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":-64
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":192,
|
||||
"y":352
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"name":"",
|
||||
"polyline":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":-64
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":-128
|
||||
},
|
||||
{
|
||||
"x":160,
|
||||
"y":-128
|
||||
},
|
||||
{
|
||||
"x":192,
|
||||
"y":-160
|
||||
},
|
||||
{
|
||||
"x":256,
|
||||
"y":-160
|
||||
},
|
||||
{
|
||||
"x":256,
|
||||
"y":-128
|
||||
},
|
||||
{
|
||||
"x":288,
|
||||
"y":-128
|
||||
},
|
||||
{
|
||||
"x":288,
|
||||
"y":-160
|
||||
},
|
||||
{
|
||||
"x":352,
|
||||
"y":-160
|
||||
},
|
||||
{
|
||||
"x":352,
|
||||
"y":-128
|
||||
},
|
||||
{
|
||||
"x":288,
|
||||
"y":-128
|
||||
},
|
||||
{
|
||||
"x":288,
|
||||
"y":-96
|
||||
},
|
||||
{
|
||||
"x":128,
|
||||
"y":-96
|
||||
},
|
||||
{
|
||||
"x":128,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":256,
|
||||
"y":480
|
||||
},
|
||||
{
|
||||
"ellipse":true,
|
||||
"height":64,
|
||||
"name":"",
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":64,
|
||||
"x":704,
|
||||
"y":288
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"name":"",
|
||||
"polygon":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":0
|
||||
}],
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":416,
|
||||
"y":544
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"name":"",
|
||||
"polyline":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":-64
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":-64
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":-32
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":64,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":608,
|
||||
"y":480
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"name":"",
|
||||
"polygon":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":96,
|
||||
"y":-64
|
||||
},
|
||||
{
|
||||
"x":192,
|
||||
"y":0
|
||||
}],
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":736,
|
||||
"y":544
|
||||
},
|
||||
{
|
||||
"height":0,
|
||||
"name":"",
|
||||
"polyline":[
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":-32,
|
||||
"y":0
|
||||
},
|
||||
{
|
||||
"x":-32,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":-64,
|
||||
"y":64
|
||||
},
|
||||
{
|
||||
"x":-64,
|
||||
"y":96
|
||||
},
|
||||
{
|
||||
"x":-32,
|
||||
"y":128
|
||||
},
|
||||
{
|
||||
"x":-64,
|
||||
"y":128
|
||||
},
|
||||
{
|
||||
"x":-64,
|
||||
"y":192
|
||||
},
|
||||
{
|
||||
"x":-32,
|
||||
"y":224
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":224
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":192
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":128
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":128
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":96
|
||||
},
|
||||
{
|
||||
"x":32,
|
||||
"y":64
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":32
|
||||
},
|
||||
{
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"type":"",
|
||||
"visible":true,
|
||||
"width":0,
|
||||
"x":1472,
|
||||
"y":64
|
||||
}],
|
||||
"opacity":1,
|
||||
"type":"objectgroup",
|
||||
"visible":true,
|
||||
"width":50,
|
||||
"x":0,
|
||||
"y":0
|
||||
}],
|
||||
"orientation":"orthogonal",
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"tileheight":32,
|
||||
"tilesets":[
|
||||
{
|
||||
"firstgid":1,
|
||||
"image":"..\/tiles\/ground_1x1.png",
|
||||
"imageheight":32,
|
||||
"imagewidth":800,
|
||||
"margin":0,
|
||||
"name":"ground_1x1",
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"spacing":0,
|
||||
"tileheight":32,
|
||||
"tileproperties":
|
||||
{
|
||||
"1":
|
||||
{
|
||||
"bounce":"1"
|
||||
}
|
||||
},
|
||||
"tilewidth":32
|
||||
},
|
||||
{
|
||||
"firstgid":26,
|
||||
"image":"..\/tiles\/walls_1x2.png",
|
||||
"imageheight":64,
|
||||
"imagewidth":256,
|
||||
"margin":0,
|
||||
"name":"walls_1x2",
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"spacing":0,
|
||||
"tileheight":64,
|
||||
"tilewidth":32
|
||||
},
|
||||
{
|
||||
"firstgid":34,
|
||||
"image":"..\/..\/sprites\/coin.png",
|
||||
"imageheight":32,
|
||||
"imagewidth":192,
|
||||
"margin":0,
|
||||
"name":"coin",
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"spacing":0,
|
||||
"tileheight":32,
|
||||
"tilewidth":32
|
||||
},
|
||||
{
|
||||
"firstgid":40,
|
||||
"image":"..\/tiles\/tiles2.png",
|
||||
"imageheight":910,
|
||||
"imagewidth":840,
|
||||
"margin":0,
|
||||
"name":"tiles2",
|
||||
"properties":
|
||||
{
|
||||
|
||||
},
|
||||
"spacing":0,
|
||||
"tileheight":70,
|
||||
"tilewidth":70
|
||||
}],
|
||||
"tilewidth":32,
|
||||
"version":1,
|
||||
"width":50
|
||||
}
|
72
examples/assets/tilemaps/tmx/collision test.tmx
Normal file
72
examples/assets/tilemaps/tmx/collision test.tmx
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.0" orientation="orthogonal" width="50" height="18" tilewidth="32" tileheight="32">
|
||||
<tileset firstgid="1" name="ground_1x1" tilewidth="32" tileheight="32">
|
||||
<image source="../tiles/ground_1x1.png" width="800" height="32"/>
|
||||
<tile id="1">
|
||||
<properties>
|
||||
<property name="bounce" value="1"/>
|
||||
</properties>
|
||||
</tile>
|
||||
</tileset>
|
||||
<tileset firstgid="26" name="walls_1x2" tilewidth="32" tileheight="64">
|
||||
<image source="../tiles/walls_1x2.png" width="256" height="64"/>
|
||||
</tileset>
|
||||
<tileset firstgid="34" name="coin" tilewidth="32" tileheight="32">
|
||||
<image source="../../sprites/coin.png" width="192" height="32"/>
|
||||
</tileset>
|
||||
<tileset firstgid="40" name="tiles2" tilewidth="70" tileheight="70">
|
||||
<image source="../tiles/tiles2.png" width="840" height="910"/>
|
||||
</tileset>
|
||||
<layer name="Tile Layer 1" width="50" height="18">
|
||||
<properties>
|
||||
<property name="collides" value="true"/>
|
||||
</properties>
|
||||
<data encoding="base64">
|
||||
AQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAACQAAAAEAAAABAAAAAQAAAAEAAAABAAAACQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAA
|
||||
</data>
|
||||
</layer>
|
||||
<objectgroup name="collision" width="50" height="18">
|
||||
<object x="32" y="32">
|
||||
<polyline points="0,0 0,224 -32,224 -32,-32 1568,-32"/>
|
||||
</object>
|
||||
<object x="64" y="160">
|
||||
<polyline points="0,0 0,-32 32,-32 32,-64 128,-64 128,-32 160,-32 160,0 0,0"/>
|
||||
</object>
|
||||
<object x="416" y="96">
|
||||
<polyline points="0,0 0,32 96,32 96,64 256,64 256,96 352,96 352,64 256,64 256,32 128,32 96,0 0,0"/>
|
||||
</object>
|
||||
<object x="0" y="320">
|
||||
<polyline points="0,0 32,0 96,32 160,32 160,64 32,64 32,224 960,224 960,160 992,128 1024,128 1024,64 928,64 896,32 896,0 928,0 960,32 992,0 992,-128 1024,-128 1024,-160 1088,-160 1088,-128 1120,-128 1120,32 1152,32 1184,0 1184,-64 1216,-64"/>
|
||||
</object>
|
||||
<object x="1216" y="256">
|
||||
<polyline points="0,0 96,0 96,32 64,32 64,64 0,64 0,96 -32,128 -128,128 -128,192 -96,192 -64,224 -64,288 320,288"/>
|
||||
</object>
|
||||
<object x="1536" y="544">
|
||||
<polyline points="0,0 32,0 32,-512 -256,-512 -256,-480 -352,-480 -352,-512 -1152,-512"/>
|
||||
</object>
|
||||
<object x="384" y="32">
|
||||
<polyline points="0,0 -352,0"/>
|
||||
</object>
|
||||
<object name="platform" x="192" y="352">
|
||||
<polyline points="0,0 0,-32 32,-64 64,-64 64,-96 128,-96 160,-128 192,-128 192,-96 160,-64 96,-64 96,-32 32,-32 32,0 0,0"/>
|
||||
</object>
|
||||
<object x="256" y="480">
|
||||
<polyline points="0,0 0,-32 32,-32 64,-32 96,-64 96,-128 160,-128 192,-160 256,-160 256,-128 288,-128 288,-160 352,-160 352,-128 288,-128 288,-96 128,-96 128,-32 96,0 0,0"/>
|
||||
</object>
|
||||
<object x="704" y="288" width="64" height="64">
|
||||
<ellipse/>
|
||||
</object>
|
||||
<object x="416" y="544">
|
||||
<polygon points="0,0 32,-32 64,0"/>
|
||||
</object>
|
||||
<object x="608" y="480">
|
||||
<polyline points="0,0 0,-32 32,-32 32,-64 64,-64 64,-32 96,-32 96,0 64,0 64,32 32,32 32,0 0,0"/>
|
||||
</object>
|
||||
<object x="736" y="544">
|
||||
<polygon points="0,0 96,-64 192,0"/>
|
||||
</object>
|
||||
<object x="1472" y="64">
|
||||
<polyline points="0,0 -32,0 -32,32 -64,64 -64,96 -32,128 -64,128 -64,192 -32,224 0,224 32,192 32,128 0,128 32,96 32,64 0,32 0,0"/>
|
||||
</object>
|
||||
</objectgroup>
|
||||
</map>
|
88
examples/wip/tilemap1.js
Normal file
88
examples/wip/tilemap1.js
Normal file
|
@ -0,0 +1,88 @@
|
|||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
// var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.tilemap('map', 'assets/tilemaps/maps/collision_test.json', null, Phaser.Tilemap.TILED_JSON);
|
||||
game.load.image('ground_1x1', 'assets/tilemaps/tiles/ground_1x1.png');
|
||||
game.load.image('walls_1x2', 'assets/tilemaps/tiles/walls_1x2.png');
|
||||
game.load.image('tiles2', 'assets/tilemaps/tiles/tiles2.png');
|
||||
game.load.image('player', 'assets/sprites/phaser-dude.png');
|
||||
|
||||
}
|
||||
|
||||
var map;
|
||||
var tileset;
|
||||
var layer;
|
||||
var p;
|
||||
var b;
|
||||
var cursors;
|
||||
|
||||
function create() {
|
||||
|
||||
// game.stage.backgroundColor = '#787878';
|
||||
|
||||
map = game.add.tilemap('map');
|
||||
|
||||
map.addTilesetImage('ground_1x1');
|
||||
map.addTilesetImage('walls_1x2');
|
||||
map.addTilesetImage('tiles2');
|
||||
|
||||
// layer = map.createLayer('Tile Layer 1');
|
||||
|
||||
// layer.resizeWorld();
|
||||
|
||||
p = game.add.sprite(32, 32, 'player');
|
||||
|
||||
b = game.add.sprite(600, 400, 'player');
|
||||
b.physicsEnabled = true;
|
||||
// b.body.clearShapes();
|
||||
b.body.addLine(32, 0, 0, 0.2);
|
||||
|
||||
var ox = 192;
|
||||
var oy = 352;
|
||||
var data = [0,0 , 0, -32 , 32, -64 , 64, -64 , 64,-96, 128,-96, 160,-128, 192,-128, 192,-96, 160,-64, 96,-64, 96,-32, 32,-32, 32,0, 0,0];
|
||||
var output = [];
|
||||
|
||||
for (var i = 0; i < data.length; i += 2)
|
||||
{
|
||||
output.push(ox + data[i]);
|
||||
output.push(oy + data[i+1]);
|
||||
}
|
||||
|
||||
console.log(output);
|
||||
|
||||
// var re = b.body.addPolygon({}, output);
|
||||
|
||||
console.log(data.length);
|
||||
// console.log(re);
|
||||
console.log(output);
|
||||
console.log(b.body.data.shapes[0].vertices);
|
||||
|
||||
|
||||
game.camera.follow(p);
|
||||
|
||||
cursors = game.input.keyboard.createCursorKeys();
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (cursors.left.isDown)
|
||||
{
|
||||
p.x -= 4;
|
||||
}
|
||||
else if (cursors.right.isDown)
|
||||
{
|
||||
p.x += 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
// game.debug.renderCameraInfo(game.camera, 420, 320);
|
||||
game.debug.renderPhysicsBody(b.body);
|
||||
|
||||
}
|
|
@ -16,23 +16,134 @@
|
|||
*/
|
||||
Phaser.Graphics = function (game, x, y) {
|
||||
|
||||
x = x || 0;
|
||||
y = y || 0;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Game} game - A reference to the currently running Game.
|
||||
*/
|
||||
this.game = game;
|
||||
|
||||
/**
|
||||
* @property {boolean} exists - If exists = false then the Text isn't updated by the core game loop.
|
||||
* @default
|
||||
*/
|
||||
this.exists = true;
|
||||
|
||||
/**
|
||||
* @property {string} name - The user defined name given to this object.
|
||||
* @default
|
||||
*/
|
||||
this.name = '';
|
||||
|
||||
/**
|
||||
* @property {number} type - The const type of this object.
|
||||
* @default
|
||||
*/
|
||||
this.type = Phaser.GRAPHICS;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} world - The world coordinates of this Sprite. This differs from the x/y coordinates which are relative to the Sprites container.
|
||||
*/
|
||||
this.world = new Phaser.Point(x, y);
|
||||
|
||||
/**
|
||||
* @property {Phaser.Events} events - The Events you can subscribe to that are dispatched when certain things happen on this Sprite or its components.
|
||||
*/
|
||||
this.events = new Phaser.Events(this);
|
||||
|
||||
/**
|
||||
* @property {Phaser.InputHandler|null} input - The Input Handler for this object. Needs to be enabled with image.inputEnabled = true before you can use it.
|
||||
*/
|
||||
this.input = null;
|
||||
|
||||
/**
|
||||
* @property {Phaser.Point} cameraOffset - If this object is fixedToCamera then this stores the x/y offset that its drawn at, from the top-left of the camera view.
|
||||
*/
|
||||
this.cameraOffset = new Phaser.Point();
|
||||
|
||||
PIXI.Graphics.call(this);
|
||||
|
||||
/**
|
||||
* @property {number} type - The Phaser Object Type.
|
||||
*/
|
||||
this.type = Phaser.GRAPHICS;
|
||||
this.position.set(x, y);
|
||||
|
||||
this.position.x = x;
|
||||
this.position.y = y;
|
||||
/**
|
||||
* A small internal cache:
|
||||
* 0 = previous position.x
|
||||
* 1 = previous position.y
|
||||
* 2 = previous rotation
|
||||
* 3 = renderID
|
||||
* 4 = fresh? (0 = no, 1 = yes)
|
||||
* 5 = outOfBoundsFired (0 = no, 1 = yes)
|
||||
* 6 = exists (0 = no, 1 = yes)
|
||||
* 7 = fixed to camera (0 = no, 1 = yes)
|
||||
* @property {Int16Array} _cache
|
||||
* @private
|
||||
*/
|
||||
this._cache = new Int16Array([0, 0, 0, 0, 1, 0, 1, 0]);
|
||||
|
||||
};
|
||||
|
||||
Phaser.Graphics.prototype = Object.create(PIXI.Graphics.prototype);
|
||||
Phaser.Graphics.prototype.constructor = Phaser.Graphics;
|
||||
|
||||
/**
|
||||
* Automatically called by World.preUpdate.
|
||||
* @method Phaser.Graphics.prototype.preUpdate
|
||||
*/
|
||||
Phaser.Graphics.prototype.preUpdate = function () {
|
||||
|
||||
this._cache[0] = this.world.x;
|
||||
this._cache[1] = this.world.y;
|
||||
this._cache[2] = this.rotation;
|
||||
|
||||
if (!this.exists || !this.parent.exists)
|
||||
{
|
||||
this.renderOrderID = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.autoCull)
|
||||
{
|
||||
// Won't get rendered but will still get its transform updated
|
||||
this.renderable = this.game.world.camera.screenView.intersects(this.getBounds());
|
||||
}
|
||||
|
||||
this.world.setTo(this.game.camera.x + this.worldTransform[2], this.game.camera.y + this.worldTransform[5]);
|
||||
|
||||
if (this.visible)
|
||||
{
|
||||
this._cache[3] = this.game.world.currentRenderOrderID++;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Override and use this function in your own custom objects to handle any update requirements you may have.
|
||||
*
|
||||
* @method Phaser.Graphics#update
|
||||
* @memberof Phaser.Graphics
|
||||
*/
|
||||
Phaser.Graphics.prototype.update = function() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically called by World.postUpdate.
|
||||
* @method Phaser.Graphics.prototype.postUpdate
|
||||
*/
|
||||
Phaser.Graphics.prototype.postUpdate = function () {
|
||||
|
||||
// Fixed to Camera?
|
||||
if (this._cache[7] === 1)
|
||||
{
|
||||
this.position.x = this.game.camera.view.x + this.cameraOffset.x;
|
||||
this.position.y = this.game.camera.view.y + this.cameraOffset.y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy this Graphics instance.
|
||||
*
|
||||
|
@ -47,6 +158,9 @@ Phaser.Graphics.prototype.destroy = function() {
|
|||
this.parent.remove(this);
|
||||
}
|
||||
|
||||
this.exists = false;
|
||||
this.visible = false;
|
||||
|
||||
this.game = null;
|
||||
|
||||
}
|
||||
|
@ -68,3 +182,89 @@ Phaser.Graphics.prototype.drawPolygon = function (poly) {
|
|||
this.lineTo(poly.points[0].x, poly.points[0].y);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates the rotation of the Graphics, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.
|
||||
* Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement player.angle = 450 is the same as player.angle = 90.
|
||||
* If you wish to work in radians instead of degrees use the property Sprite.rotation instead.
|
||||
* @name Phaser.Graphics#angle
|
||||
* @property {number} angle - Gets or sets the angle of rotation in degrees.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Graphics.prototype, 'angle', {
|
||||
|
||||
get: function() {
|
||||
return Phaser.Math.radToDeg(this.rotation);
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.rotation = Phaser.Math.degToRad(value);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* By default a Graphics object won't process any input events at all. By setting inputEnabled to true the Phaser.InputHandler is
|
||||
* activated for this object and it will then start to process click/touch events and more.
|
||||
*
|
||||
* @name Phaser.Graphics#inputEnabled
|
||||
* @property {boolean} inputEnabled - Set to true to allow this object to receive input events.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Graphics.prototype, "inputEnabled", {
|
||||
|
||||
get: function () {
|
||||
|
||||
return (this.input && this.input.enabled);
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
if (value)
|
||||
{
|
||||
if (this.input === null)
|
||||
{
|
||||
this.input = new Phaser.InputHandler(this);
|
||||
this.input.start();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.input && this.input.enabled)
|
||||
{
|
||||
this.input.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* An Graphics that is fixed to the camera uses its x/y coordinates as offsets from the top left of the camera. These are stored in Graphics.cameraOffset.
|
||||
* Note that the cameraOffset values are in addition to any parent in the display list.
|
||||
* So if this Graphics was in a Group that has x: 200, then this will be added to the cameraOffset.x
|
||||
*
|
||||
* @name Phaser.Graphics#fixedToCamera
|
||||
* @property {boolean} fixedToCamera - Set to true to fix this Graphics to the Camera at its current world coordinates.
|
||||
*/
|
||||
Object.defineProperty(Phaser.Graphics.prototype, "fixedToCamera", {
|
||||
|
||||
get: function () {
|
||||
|
||||
return !!this._cache[7];
|
||||
|
||||
},
|
||||
|
||||
set: function (value) {
|
||||
|
||||
if (value)
|
||||
{
|
||||
this._cache[7] = 1;
|
||||
this.cameraOffset.set(this.x, this.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._cache[7] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -531,28 +531,24 @@ Phaser.Physics.Body.prototype = {
|
|||
|
||||
points = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
var path;
|
||||
var path = [];
|
||||
|
||||
// Did they pass in a single array of points?
|
||||
if (points.length === 1 && Array.isArray(points[0]))
|
||||
{
|
||||
path = points[0];
|
||||
path = path.concat(points[0]);
|
||||
}
|
||||
else if (Array.isArray(points[0]))
|
||||
{
|
||||
path = points;
|
||||
path = path.concat(points);
|
||||
}
|
||||
else if (typeof points[0] === 'number')
|
||||
{
|
||||
var temp = [];
|
||||
|
||||
// We've a list of numbers
|
||||
for (var i = 0, len = points.length; i < len; i += 2)
|
||||
{
|
||||
temp.push([points[i], points[i + 1]]);
|
||||
path.push([points[i], points[i + 1]]);
|
||||
}
|
||||
|
||||
path = temp;
|
||||
}
|
||||
|
||||
// Now process them into p2 values
|
||||
|
|
Loading…
Reference in a new issue