EditPopfly Game Creator API
EditThe Game Object
The game object persists between scenes and is responsible for transitioning between scenes, the instantiation of actors, and game-level properties.
EditGame Object Methods
GetValue
Parameters:
| Property | Type | Description |
| propertyName | String | Name of the property to be retrieved. |
Returns:
| Type | Description |
| Any Type | Value of the specified property |
Retrieves a particular property from the current game object.JavaScript:
var curScore = Game.GetValue("Score");
SetValue
Parameters:
| Property | Type | Description |
| propertyName | String | Name of the property to be set. |
| value | Any type | Value of the property. |
Set a particular property on the current game object.JavaScript:
Game.SetValue("Score", Game.GetValue("Score") + 10);
PlayAudio
Parameters:
| Property | Type | Description |
| url | String | Address containing the audio file |
| repeat | boolean | if true, audio repeats indefinitely. |
Plays the specified WMA or MP3 file.
SpawnActor
Parameters:
| Property | Type | Description |
| params | propertyBag | Name of the property to be set. |
Returns:
| Type | Description |
| Actor | The spawned actor. |
Params property bag
| Property | Type | Description |
| actor | String | Name of the actor type you would like to spawn |
| x | number (optional) | x location of the spawned actor |
| y | number (optional) | y location of the spawned actor |
| effect | property bag | contains 2 boolean flags, scale and fade. |
Spawns the an actor specified by the parameter onto the current scene.
ChangeScene
Parameters:
| Property | Type | Description |
| newSceneName | String | The name of the scene to change to. |
Changes the scene to the one specified.
EditGame Object Properties
MousePosition
Contains two subproperties:
X and
Y. They together describe the current location of the mouse relative to the scene.
JavaScript:
var curMouseX = Game.MousePosition.X;
var curMouseY = Game.MousePosition.Y;
CurrentScene
A reference to the current active scene (ie. Intro, Main or Lost)
EditScene Objects
Scene object encapulates a particular scene in the game. Like the game object, they can also have properties. However their properties only persist over the duration of the scene.
Another thing differencating scene objects and the game object is that you first need to get a reference to the scene (through something like Game.CurrentScene).
EditScene Objects Methods
GetValue
Parameters:
| Property | Type | Description |
| propertyName | String | Name of the property to be retrieved. |
Returns:
| Type | Description |
| Any Type | Value of the specified property |
Retrieves a particular property from the scene.JavaScript:
var curScene = Game.CurrentScene;
var curSceneX= curScene .GetValue("X");
SetValue
Parameters:
| Property | Type | Description |
| propertyName | String | Name of the property to be set. |
| value | Any type | Value of the property. |
Set a particular property on the scene.JavaScript:
var curScene = Game.CurrentScene;
curScene.SetValue("X", 5);
GetActors
Parameters:
| Property | Type | Description |
| Actors | Array of String | List of actor names to retrieve |
Returns:
| Type | Description |
| List of Actors | List of retrieved actors based on the actor names passed in |
Retrieves a list of actor instances based on the list of actor names passed in.JavaScript:
var curScene = Game.CurrentScene;
var actors = curScene.GetActors(["Spaceship 1", "Spaceship 2"]);
GetActor
Parameters:
| Property | Type | Description |
| Actor | String | actor name to retrieve |
Returns:
| Type | Description |
| Actor | retrieved actor based on the actor name passed in |
Retrieves an actor based on the actor name passed in.JavaScript:
var curScene = Game.CurrentScene;
var actor = curScene.GetActor("Spaceship 1");
EditActor Objects
EditActor Objects Methods
GetValue
Parameters:
| Property | Type | Description |
| propertyName | String | Name of the property to be retrieved. |
Returns:
| Type | Description |
| Any Type | Value of the specified property |
Retrieves a particular property from the actor.JavaScript:
var curActor = Game.CurrentScene.GetActor("Spaceship 1");
var curActorX= curActor.GetValue("X");
SetValue
Parameters:
| Property | Type | Description |
| propertyName | String | Name of the property to be set. |
| value | Any type | Value of the property. |
Set a particular property on the actor.JavaScript:
var curActor = Game.CurrentScene.GetActor("Spaceship 1");
curActor.SetValue("X", 5);
GetCenter
Returns:
| Type | Description |
| Point | Location of the center point of the actor relative to the scene. Contains the X and Y component. |
Retrieves the center point of the actorJavaScript:
var curActor = Game.CurrentScene.GetActor("Spaceship 1");
var curActorX= curActor.GetCenter().X;
GetCenterY
Returns:
| Type | Description |
| Integer | Location of the center point, the Y value, of the actor relative to the scene. |
Retrieves the Y value of the center point of the actorJavaScript:
var curActor = Game.CurrentScene.GetActor("Spaceship 1");
var curActorY= curActor.GetCenterY();
GetCenterX
Returns:
| Type | Description |
| Integer | Location of the center point, the X value, of the actor relative to the scene. |
Retrieves the X value of the center point of the actorJavaScript:
var curActor = Game.CurrentScene.GetActor("Spaceship 1");
var curActorX= curActor.GetCenterX();
GetPosition
Returns:
| Type | Description |
| Point | Location of the top left point of the actor relative to the scene. Contains the X and Y component. |
Retrieves the top left point of the actorJavaScript:
var curActor = Game.CurrentScene.GetActor("Spaceship 1");
var curActorX= curActor.GetPosition().X;
GetVisualRoot
Returns:
| Type | Description |
| Silverlight Element | Root canvas of the actor |
Retrieves the root canvas of the actor
ChangeState
Parameters:
| Property | Type | Description |
| newStateName | String | The name of the stateto change to. |
Changes the state to the one specified.
IsOffScene
Returns:
| Type | Description |
| Boolean | true if the actor is currently off-screen |
Check if the actor is currently offscreen.
Remove
Parameters:
| Property | Type | Description |
| effect | property bag | contains 2 boolean flags, scale and fadein. |
Removes the actor from the scene with the specified effect
currentState
Object:
| Property | Type | Description |
| name | string | contains the actuale name of the state. |
| width | integer | Contains the width of the Actor in this state. |
| height | integer | Contains the height of the Actor in this state. |
| isSolid | boolean | Returns true or false wether the Actor is an solid. |
| xaml | string | Returns the complete XAML value for this state. |
| egdes | uknown | unknown |
Returns an object with the above properties.JavaScript:
var curActor = Game.CurrentScene.GetActor("Spaceship 1");
var currentState = curActor.currentState.name;