hey guys I'm having trouble with making my actor/player stop directly at a wall and wait until it is moved) can only move on the x or y axis
the problem is when the player is touching a wall it bounces and i dont want it to
public class Pacman extends Actor
{
private int timer;
public int mCounter = 0;
public int mChange = 10;
public int qCounter = -10;
public int Death = 0;
public int life = 1;
public int stop = 0;
GreenfootSound Respawn = new GreenfootSound("Respawn.wav");
GreenfootSound Fail = new GreenfootSound("Fail Sound.mp3");
public void act()
{
//Pacman_Hitbox();
[b] movement();[/b]
Animation();
DeathAnimation();
[b] NoClipOff();
if (Death == 0){
move(2);
}[/b]
}
//Mouth Animation
private void Animation()
{
if (Death == 0){
mCounter++;
if (mCounter >= mChange)
{
setImage("Pacman1.png");
if(mCounter == 2*mChange) mCounter = 0;
}
else setImage("Pacman2.png");
}
}
//Death Animation
private void DeathAnimation()
{
if (life==0){
Death = 1;
qCounter++;
if (qCounter == 0){
setImage("PacmanDeath1.png");
}
else if (qCounter == 10){
setImage("PacmanDeath2.png");
}
else if (qCounter == 15){
setImage("PacmanDeath3.png");
}
else if (qCounter == 20){
setImage("PacmanDeath4.png");
}
else if (qCounter == 25){
setImage("PacmanDeath5.png");
}
else if (qCounter == 30){
setImage("PacmanDeath6.png");
}
else if (qCounter == 35){
setImage("PacmanDeath7.png");
}
else if (qCounter == 40){
setImage("PacmanDeath8.png");
}
else if (qCounter == 45){
setImage("PacmanDeath9.png");
}
else if (qCounter == 50){
setImage("PacmanDeath10.png");
}
else if (qCounter == 55){
setImage("PacmanDeath11.png");
}
else if (qCounter == 60){
setImage("PacmanDeath12.png");
}
else if (qCounter == 100){
setImage("Bounds.png");
Greenfoot.setWorld(new PacWorld());
}
}
}
[b] public void movement()
{
if (isTouching(Wall.class))
{
if (Greenfoot.isKeyDown("w"))
{
if (isTouching(Intercection.class)){
setLocation(getX()+2, getY());
setRotation(270);
}
}
if (Greenfoot.isKeyDown("a"))
{
if (isTouching(Intercection.class)){
setLocation(getX(), getY());
setRotation(180);
}
}
if (Greenfoot.isKeyDown("s"))
{
if (isTouching(Intercection.class)){
setLocation(getX()-2, getY());
setRotation(90);
}
}
if (Greenfoot.isKeyDown("d"))
{
if (isTouching(Intercection.class)){
setLocation(getX(), getY()-2);
setRotation(0);
}
}
}
}
public void NoClipOff()
{
if (isTouching(Wall.class))
{
getIntersectingObjects(Wall.class);
//move(0);
//setLocation(getX()-2, getY());
setLocation(getX()-2, getY());
//wait(stop );
}
}[/b]
}public void act()
{
move(2);
if (isTouching(Wall.class)) move(-2);
} public void act()
{
//Pacman_Hitbox();
movement();
Animation();
DeathAnimation();
NoClipOff();
if (Death == 0){
move(2);
if (isTouching(Wall.class)) move(-2);
}
}