This site requires JavaScript, please enable it in your browser!
Greenfoot back
Greenfootnoob
Greenfootnoob wrote ...

2014/4/15

stopping by walls

Greenfootnoob Greenfootnoob

2014/4/15

#
can anyone help me with this? first of all,it says it cannot find spriteWidth. and finally it says it connote find 'stopByRightWall'.
public boolean checkRightWalls()
    {
        int spriteHeight= getImage().getWidth();
        int xDistance= (int)(spriteHeight/2);

        Actor rightWall = getOneObjectAtOffset(xDistance, 0, Platform.class);

        if(rightWall == null)
        {
            return false;
        }
        else
        {
            stopByRightWall (rightWall);
            return true;
        }
    }

    public void stopByRightWorld(Actor rightWall)
    {
        int wallWidth = rightWall.getImage().getWidth();
        int newX = rightWall.getX() -(wallWidth + getImage(). getWidth())/2;

        setLocation(newX- 5,getY());
    }
danpost danpost

2014/4/15

#
You named the method incorrectly on line 19.
You need to login to post a reply.