Here’s the code of my world which is called TestWorld1:
package {
import net.flashpunk.World;
import net.flashpunk.FP;
import net.flashpunk.utils.*;
public class TestWorld1 extends World{
public function TestWorld1() {
add(new Player(50,50));
}
override public function update():void
{
var player = world.getInstance("player") as Player;
}
}
And here is the code for my Entity which is called Player:
package {
import net.flashpunk.Entity;
import net.flashpunk.utils.*;
import net.flashpunk.Graphic;
import net.flashpunk.graphics.Image;
import net.flashpunk.graphics.Spritemap;
public class Player extends Entity{
[Embed(source = 'assets/hatman.png')]
private const HATMAN:Class;
public var sprHatman:Spritemap = new Spritemap(HATMAN, 30, 62);
public function Player(x:Number,y:Number) {
super(x,y);
sprHatman.add("stand",[0], 20, true);
sprHatman.add("walk",[1,2,3], 20, true);
graphic = sprHatman;
sprHatman.play('stand');
name = 'player';
}
}
And here is the error I am getting:
/Users/npollema16/Desktop/My Stuff/Flash Stuff/Games/To
bed/TestWorld1.as, Line 9 1120: Access of undefined property world.