So everything is self explanatory, I want to change world when space is pressed, and one of enteties is checking for that. But i recieve this error:
‘Cannot access a property or method of a null object reference.’
here is my code
package { import net.flashpunk.Entity; import net.flashpunk.graphics.Text; import net.flashpunk.utils.Input; import net.flashpunk.utils.Key; import net.flashpunk.FP;
/**
* ...
* @author bootcher007
*/
public class starttext extends Entity
{
var txt:Text;
var cnt:int;
public function starttext()
{
cnt = 0;
txt = new Text("Pres Spacebar to start!");
graphic = txt;
txt.scale = 3;
}
public override function update():void
{
if (cnt <= 20)
{
txt.text = "";
cnt++;
}
else if(cnt > 20)
{
cnt++;
txt.text = "Pres Spacebar to start!";
}
if(cnt > 40)
{
cnt=0;
}
if (Input.check(Key.SPACE))
{
FP.world = new Level;
}
}
}
}