Is it possible to check a Boolean from one actor using another actor?
I am trying to detect if a wall is on one side of an actor (ball) and if the other side also has an actor (player).
I want to do this because my player pushing the ball into ends up on top of the ball
The following code is in the ball so it is detecting whether a wall and player are at opposites of the ball:
public void edgeCollision ()
{
Actor edge;
Actor player;
boolean edgeLeft;
boolean edgeRight;
boolean edgeAbove;
boolean edgeBelow;
edge=getOneObjectAtOffset(-10,0,edge.class);
player=getOneObjectAtOffset(10,0,player.class);
if (edge !=null && player!=null)
{
edgeLeft = true;
}
else
{
edgeLeft = false;
}
edge=getOneObjectAtOffset(10,0,edge.class);
player=getOneObjectAtOffset(-10,0,player.class);
if (edge !=null && player!=null)
{
edgeRight = true;
}
else
{
edgeRight = false;
}
edge=getOneObjectAtOffset(0,10,edge.class);
player=getOneObjectAtOffset(0,-10,player.class);
if (edge !=null && player!=null)
{
edgeAbove = true;
}
else
{
edgeAbove = false;
}
edge=getOneObjectAtOffset(0,-10,edge.class);
player=getOneObjectAtOffset(0,10,player.class);
if (edge !=null && player!=null)
{
edgeBelow = true;
}
else
{
edgeBelow = false;
}
I then want to call upon the edgeLeft, edgeRight, etc in another actor? Is this possible?
Thanks for reading!