I was just about to edit the post above to explain more in detail where the problem lays.
I don’t have any variables in the added() function of my player that doing problems i guess. also i don’t have any global static yet since i read here so often that you shoudl try to avoid em. but can you change the value of a static variable? that would be quite cool to know
i will post now in this one here and more in detail desription of the problem. i think its working cause of coincidence but maybe i’m just too un-experienced? maybe it shouldn’t work at all x:
So i got 3 world classes to show: endtraume (kind of a preworld just to create a new instance for my hero so i dont need to create it in the other worlds and maybe to create all instances of entities for the game if that makes sense ), aufwachen (the first level, fobb (the player) appears), morgentau (the second level).
I want fobb be able to move freely between the worlds without any changes of entities like plants or variables like collected plants caused through the levelchange.
endtraume looks like this:
public function endtraume()
{
super();
FOBB = new fobb();
add(FOBB);
}
override public function begin():void
{
super.begin();
var _Aufwachen:aufwachen = new aufwachen(A.aufauf);
_Aufwachen.addFOBB(FOBB, _Aufwachen.mapXML...x, _Aufwachen.mapXML...y);
FP.world = _Aufwachen;
removeAll()
}
aufwachen is next, the player appears so does some plants. the constructor() and the begin() are looking casual. the intersteing part should be the addFOBB() function (and the same endThis() like before just this one gets triggered through collision
public function addFOBB(_FOBB:fobb, x:Number = 0, y:Number = 0):void
{
FOBB = _FOBB;
FOBB.x = x;
FOBB.y = y;
add(FOBB)
}
protected function endThis():void
{
var _Morgentau:morgentau = new morgentau(A.moin, FP.world);
FP.world = _Morgentau;
_Morgentau.addFOBB(FOBB, _Morgentau.mapXML...x, _Morgentau.mapXML...y);
remove(FOBB);
}
and the thrid one, level2 morgentau. here its getting interesting because when i go back from morgentau to aufwachen everything is as i wish, only that its +1 entity i can explain (if the world would be added completly new there must been more new entities. but its only one so i think its fobb doubled)
private var letzteWelt:World;
public function morgentau(mapData:Class = null, wokommichher:World = null)
{
super();
letzteWelt = wokommichher;
}
public function addFOBB(_FOBB:fobb, x:Number = 0, y:Number = 0):void
{
FOBB = _FOBB;
FOBB.x = x;
FOBB.y = y;
add(FOBB)
}
protected function getBack():void
{
var _Aufwachen:aufwachen = new aufwachen(A.aufauf);
_Aufwachen.addFOBB(FOBB, _Aufwachen.mapXML...x, _Aufwachen.mapXML...y);
FP.world = letzteWelt;
letzteWelt.add(FOBB);
remove(FOBB)
}
i’m quite confused, maybe you can see something in there?
(hopefully its not too messy posted)