vendredi 17 juin 2016

Changing world's in flashpunk

I'm trying to make my first actual game in AS3, for this I am using flashpunk due to it's simplicity.

I have got to the point where I have a moving character and a textbox when I go infront of a door.

When I am infront of a door, two variables are changed inside the player class:

public var onDoor:Boolean = false;
public var doorType:String = ""

You can probably guess what onDoor does, doorType is the name the class. It's set like this:

    public static var BedroomDoor:Door = new Door(350, 331, "ApartmentBedroom")

ApartmenBedroom being the name of the world the door leads to.

Inside the main class where flashpunk is initialised, I have this function:

    public static function ChangeLevel(world:String)
        var newWorld = getDefinitionByName(world) as Class = new newWorld

But when I go to the door and press X infront of the door which calls the function, I always get this error:

[Fault] exception, information=ReferenceError: Error #1065: Variable ApartmentBedroom is not defined.

Can anyone help fix this?

Aucun commentaire:

Enregistrer un commentaire