Hi there, I have four dynamic text fields, each saying 'Left', 'Right', 'Up' and 'Down'. When my main character hits an object, the respective directional text is blanked out (i.e. if the character hit an object on its right, the 'Right' text would display nothing).
Here is the function below:
Actionscript Code:
hero.mc.addEventListener(Event.ENTER_FRAME, hithomeblocks);
function hithomeblocks(event:Event):void{
hero.mc.point = new Point(hero.mc.x, hero.mc.y);
while(level.mc.mcHomeBlocks.hitTestPoint(hero.mc.point.x, (hero.mc.point.y - (hero.mc.height)), true)) {
up = false;
mctxtUp.txtUp.text = "";
break;
}
while(level.mc.mcHomeBlocks.hitTestPoint((hero.mc.point.x - (hero.mc.width)), hero.mc.point.y, true)) {
left = false;
mctxtLeft.txtLeft.text = "";
break;
}
while(level.mc.mcHomeBlocks.hitTestPoint(hero.mc.point.x, (hero.mc.point.y + (hero.mc.height)), true)) {
down = false;
mctxtDown.txtDown.text = "";
break;
}
while(level.mc.mcHomeBlocks.hitTestPoint((hero.mc.point.x + (hero.mc.width)), hero.mc.point.y, true)) {
right = false;
mctxtRight.txtRight.text = "";
break;
}
}
Which works fine. However, I would like to add a function where whenever the character isn't touching an object on one side, the text linked to that side is displayed again. So if the character walked away from an object on his right, the 'Right' text would display 'Right' again.
Does anyone know how to do this?
P.S. I tried this:
Actionscript Code:
while(level.mc.mcHomeBlocks.hitTestPoint((hero.mc.point.x + (hero.mc.width)), hero.mc.point.y, false)) {
mctxtRight.txtRight.text = "Right";
break;
}
But that just made the text permanently display 'Right'.