From 4adbeaa21c3a29ebe636fc5688bf62bab4625d9b Mon Sep 17 00:00:00 2001 From: nickquach02 <54787606+nickquach02@users.noreply.github.com> Date: Thu, 9 Jan 2020 10:32:20 -0500 Subject: [PATCH] Update MapLoader.kt --- .../me/srikavin/fbla/game/map/MapLoader.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/src/me/srikavin/fbla/game/map/MapLoader.kt b/core/src/me/srikavin/fbla/game/map/MapLoader.kt index e221059..4266e16 100644 --- a/core/src/me/srikavin/fbla/game/map/MapLoader.kt +++ b/core/src/me/srikavin/fbla/game/map/MapLoader.kt @@ -179,6 +179,23 @@ class MapLoader { createCoin(world, mapObject.rectangle.getPosition(pos).scl(MAP_SCALE_FACTOR)) info { "Making coin at $pos" } } + TriggerType.values().any { it.name == type.toUpperCase() } -> { + val rect = mapObject.rectangle + + world.createEntity().edit() + .add(Transform().apply { position = rect.getCenter(recycledVector2).scl(MAP_SCALE_FACTOR).cpy() }) + .add(PhysicsBody().apply { + shape = PolygonShape().apply { + setAsBox(rect.width * MAP_SCALE_FACTOR * .5f, rect.height * MAP_SCALE_FACTOR * .5f, + recycledVector2.setZero(), 0f) + } + this.type = BodyDef.BodyType.StaticBody + }) + .add(MapTrigger().apply { + this.type = TriggerType.valueOf(type.toUpperCase()) + properties = mapObject.properties + }) + } type == "damage" -> { // val rect = mapObject.rectangle @@ -297,4 +314,4 @@ class MapLoader { return mapEntity } -} \ No newline at end of file +}