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

2016/10/19

isTouching being Private

1
2
Psychpsyo Psychpsyo

2016/10/21

#
Then it would have to be a sphere. (and I tried things like getOneIntersectingObject already. Same problem)
danpost danpost

2016/10/21

#
Psychpsyo wrote...
Then it would have to be a sphere. (and I tried things like getOneIntersectingObject already. Same problem)
There is also 'getObjectsInRange'.
Nosson1459 Nosson1459

2016/10/21

#
danpost wrote...
What about using a different collision method, like 'getObjectsInRange', for example?
danpost wrote...
There is also 'getObjectsInRange'.
basically said the same thing two times in a row
danpost danpost

2016/10/21

#
Nosson1459 wrote...
basically said the same thing two times in a row
Guess I did! Actually, I meant to suggest using 'getNeighbours', which can be used to make a variable size square or diamond hitbox.
Psychpsyo Psychpsyo

2016/10/21

#
danpost wrote...
Nosson1459 wrote...
basically said the same thing two times in a row
Guess I did! Actually, I meant to suggest using 'getNeighbours', which can be used to make a variable size square or diamond hitbox.
But a square shape can't be higher than wide.
danpost danpost

2016/10/21

#
Psychpsyo wrote...
But a square shape can't be higher than wide.
No, it cannot. However, there are other things you can do using one or more of these methods. For example, you can relocate the actor, temporarily, and check collision at various nearby locations using one of them. Here is one possible way:
if (collisionLow(10, 25) || collisionHigh(10, 25))

// with these methods
private boolean collisionLow(int down, int range)
{
    setLocation(getX(), getY()+down);
    boolean collision = getNeighbours(range, true, null);
    setLocation(getX(), getY()-down);
    return collision;
}
// and
private boolean collisionHigh(int up, int range)
{
    setLocation(getX(), getY()-up);
    boolean collision = getNeighbours(range, true, null);
    setLocation(getX(), getY()+up);
    return collision;
}
This would check an area 70 high and 50 wide.
You need to login to post a reply.
1
2