@Override public void beginContact(Contact contact) { Entity monster = PhysicsSys.getEntityFromBodyData(UserData.Type.MONSTER, contact); if (monster != null) { MonsterComp m = monster.getComponent(MonsterComp.class); if (m.type == MonsterComp.Type.PLATFORM_MONSTER) { Entity wall = PhysicsSys.getEntityFromBodyData(UserData.Type.WALL, contact); if (wall != null) { Vector2 wallPos = getPos(wall); Vector2 monsterPos = getPos(monster); PlatformMonsterComp pm = monster.getComponent(PlatformMonsterComp.class); if (wallPos.x < monsterPos.x) { pm.minX = wallPos.x + 5f; } else { pm.maxX = wallPos.x - 5f; } } } } }
public void removedFromEngine(Engine e) { super.removedFromEngine(e); phisicsSys.removeListener(this); }
public void addedToEngine(Engine e) { super.addedToEngine(e); phisicsSys.addListener(this); }