I am trying to figure out how to make it so that when the Enemy image is set to the one of it facing left, it will shoot left and then when it faces right I want it to shoot right. Here is the code I have so far and currently it does nothing. I'm not sure how to get it working so if anyone could help out then thank you very much!
Also I should add that I took this code and changed it a little bit from another that was needing something similar but for my need it is not working out.
private int spawnTimer; private GreenfootImage EnemyRight = new GreenfootImage("EnemyRight.png"); private GreenfootImage EnemyLeft = new GreenfootImage("Enemy.png"); private int minShotDelay = 40; private int maxShotDelay = 160; private int shotTimer = minShotDelay; // in 'act' method or a 'spawnBullet' method it calls private void checkForSpawning() // call from act method { spawnTimer = (spawnTimer+1)%600; // repeat every 10 seconds (about) if (spawnTimer == 0) // at each timer reset { { if (getImage().equals(EnemyRight)) { getWorld().addObject(new vomitRight(getRotation()), getX(), getY()); shotTimer = minShotDelay+Greenfoot.getRandomNumber(1+maxShotDelay-minShotDelay); } else if (getImage().equals(EnemyLeft)) { getWorld().addObject(new vomitLeft(getRotation()), getX(), getY()); shotTimer = minShotDelay+Greenfoot.getRandomNumber(1+maxShotDelay-minShotDelay); } else shotTimer--; } } }