Hi gentlemen! I’m looking for an Entity object that, after collecting all the same entity inside of the same level, allow you to swap to a different World.
For now i’m cooding these:
package {
import net.flashpunk.Entity;
import net.flashpunk.graphics.Image;
import net.flashpunk.FP;
public class Coin extends Entity
{
[Embed(source = "../assets/moneta pinco.png")]
private const MONETA: Class;
private var n:int = FP.world.classCount(Coin);
public function Coin(posx:int, posy:int)
{
graphic = new Image(MONETA);
setHitbox(30, 30);
type = 'coin';
x = posx * 20;
y = posy * 20;
}
override public function update():void
{
if (collide('player',x,y))
{
n --;
FP.world.remove(this);
if (n==0)
{
FP.world = new W_gameplay();
}
}
}
} }
But, obviously, it doesn’t work! Somebody know why?