Greetings, can you give me a code that when you touch an object, it slows down the enemy for a while, thanks


public class SlowDownWorld extends World { private int slowDownTimer = 0; public void slowDownEnemies() { slowDownTimer = 300; } public boolean isSlowedDown() { return slowDownTimer > 0; } @Override public void act() { if (slowDownTimer > 0) { --slowDownTimer; } } }
public class Enemy extends Actor { @Override public void move(final int distance) { // positive value for distance is expected final SlowDownWorld world = (SlowDownWorld)getWorld(); final int actualDistance = world != null && world.isSlowedDown() ? distance - 1 /* else */ : distance; super.move(actualDistance); } }
public class You extends Actor { @Override public void act() { final Actor freezer = getOneIntersectingObject(SlowDownObject.class); final SlowDownWorld world = (SlowDownWorld)getWorld(); if (freezer != null && world != null) { world.removeObject(freezer); world.slowDownEnemies(); } } }