Hi again!
I have new problem ><
There is big pool (buoyancy box), submarine and "end bar" (the end of the level line). Submarine swims perfect, but it doesn't contact the end bar. Without pool it works fine, so the problem is in pool.
Here is my code (deleted other functions (move submarine and etc)):
I have new problem ><
There is big pool (buoyancy box), submarine and "end bar" (the end of the level line). Submarine swims perfect, but it doesn't contact the end bar. Without pool it works fine, so the problem is in pool.
Here is my code (deleted other functions (move submarine and etc)):
Code:
public class Submarine extends BodyShape
{
private var contacts:ContactList;
public var endFlag:Boolean = false;
public var isEnd:Boolean = false;
public override function create():void {
reportBeginContact = true;
reportEndContact = true;
super.create();
contacts = new ContactList();
contacts.listenTo(this);
listenWhileVisible(this, ContactEvent.BEGIN_CONTACT, this_beginContactHandler, false, 0, true);
}
private function this_beginContactHandler(e:ContactEvent):void{
var endBar:EndBar = e.other.m_userData as EndBar;;
contacts.clean();
if (endBar) {
endFlag = true;
isEnd = true;
endBar.remove();
trace("Level is end submarine");
}
}
}
{
private var contacts:ContactList;
public var endFlag:Boolean = false;
public var isEnd:Boolean = false;
public override function create():void {
reportBeginContact = true;
reportEndContact = true;
super.create();
contacts = new ContactList();
contacts.listenTo(this);
listenWhileVisible(this, ContactEvent.BEGIN_CONTACT, this_beginContactHandler, false, 0, true);
}
private function this_beginContactHandler(e:ContactEvent):void{
var endBar:EndBar = e.other.m_userData as EndBar;;
contacts.clean();
if (endBar) {
endFlag = true;
isEnd = true;
endBar.remove();
trace("Level is end submarine");
}
}
}