Skip to content

Commit e19e9e6

Browse files
committed
Fix for only one parallax value being set. (#45)
1 parent 82122c3 commit e19e9e6

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

pytiled_parser/layer.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,15 @@ def _get_common_attributes(raw_layer: RawLayer) -> Layer:
356356
if raw_layer.get("properties") is not None:
357357
common_attributes.properties = properties_.cast(raw_layer["properties"])
358358

359+
parallax = [1.0, 1.0]
360+
359361
if raw_layer.get("parallaxx") is not None:
360-
common_attributes.parallax_factor = OrderedPair(
361-
raw_layer["parallaxx"], raw_layer["parallaxy"]
362-
)
362+
parallax[0] = raw_layer["parallaxx"]
363+
364+
if raw_layer.get("parallaxy") is not None:
365+
parallax[1] = raw_layer["parallaxy"]
366+
367+
common_attributes.parallax_factor = OrderedPair(parallax[0], parallax[1])
363368

364369
if raw_layer.get("tintcolor") is not None:
365370
common_attributes.tint_color = parse_color(raw_layer["tintcolor"])

tests/test_data/layer_tests/all_layer_types/expected.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
opacity=1,
8484
visible=True,
8585
id=4,
86-
parallax_factor=common_types.OrderedPair(2.3, 1.2),
86+
parallax_factor=common_types.OrderedPair(1.4, 1.0),
8787
tint_color=common_types.Color(0, 0, 255, 255),
8888
layers=[
8989
layer.ObjectLayer(
@@ -122,7 +122,7 @@
122122
opacity=1,
123123
visible=True,
124124
id=5,
125-
parallax_factor=common_types.OrderedPair(1.5, 1.2),
125+
parallax_factor=common_types.OrderedPair(1.0, 1.4),
126126
image=Path("../../images/tile_04.png"),
127127
),
128128
]

tests/test_data/layer_tests/all_layer_types/map.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@
5252
}],
5353
"name":"Group 1",
5454
"opacity":1,
55-
"parallaxx":2.3,
56-
"parallaxy":1.2,
55+
"parallaxx":1.4,
5756
"tintcolor":"#0000ff",
5857
"type":"group",
5958
"visible":true,
@@ -79,8 +78,7 @@
7978
"image":"..\/..\/images\/tile_04.png",
8079
"name":"Image Layer 2",
8180
"opacity":1,
82-
"parallaxx":1.5,
83-
"parallaxy":1.2,
81+
"parallaxy":1.4,
8482
"type":"imagelayer",
8583
"visible":true,
8684
"x":0,

0 commit comments

Comments
 (0)