removeList problems[SOLVED]


(billy2000) #1

Hello guys. So in my game when my player dies i want to respawn him at a checkpoint.But once i respawn him , i want to remove some entities also with him and respawn them too.And here is where i have problems.The code looks like this:

protected function reloadAtCheckpoint(mapData:Class):void
	{
		var mapXML:XML = FP.getXML(mapData);
		
		//removing existing entities if they are 
		removeList(UnstableBlock, Crate, Amunition, EnemyBlue);
		//respawning entities
		addRespawnEntities(mapXML);
	}

When in my world this function is called the game breaks and it gives me this error: TypeError: Error #1034: Type Coercion failed: cannot convert UnstableBlock$ to net.flashpunk.Entity.

I don’t really know how to solve it/or if i’m using removeList correctly. Any tips/ideas? ty :smiley:


(Bora Kasap) #2

it’s probably going to give same errors for “crate”, “amunition” and “enemyblue”…

so, we need more code then we can help you about that…

what about posting

  • where you defined these variables “unsableblock,crate,amunition,enemyblue”

(Ultima2876) #3

The documentation for removeList isn’t great for beginners. What you need to do is provide a list of actual entities, not a list of types (as I’m assuming you’re doing). So something like this:

var myList: Array = new Array;
//put all entities of the specified types into myList
getClass(UnstableBlock, myList);
getClass(Crate, myList);
getClass(Amunition, myList);
getClass(EnemyBlue, myList);

//remove the entities
removeList(myList);

(billy2000) #4

Well pretty much thats the code.


(billy2000) #5

Yep thats what i was doing. Leme see if it’ll work after the changes :smile:


(billy2000) #6

Ah i understand now. Yep that solved the problem. Tyvm :smiley:


(Ultima2876) #7

No problem! Glad it worked.