Popfly Game Creator API

Modified: 2008/05/23 23:15 by 83.86.159.234 - Categorized as: Game Creator


Edit

Popfly Game Creator API

Table of Contents [Hide/Show]


Popfly Game Creator API
   The Game Object
       Game Object Methods
         GetValue
         SetValue
         PlayAudio
         SpawnActor
         ChangeScene
       Game Object Properties
         MousePosition
         CurrentScene
    Scene Objects
       Scene Objects Methods
         GetValue
         SetValue
         GetActors
         GetActor
         RemoveEventListener
         AddEventListener
    Actor Objects
       Actor Objects Methods
         GetValue
         SetValue
         GetCenter
         GetCenterY
         GetCenterX
         GetPosition
         GetVisualRoot
         AddEventListener
         RemoveEventListener
         ChangeState
         IsOffScene
         Remove
         currentState

Edit

The Game Object


The game object persists between scenes and is responsible for transitioning between scenes, the instantiation of actors, and game-level properties.

Edit

Game Object Methods

GetValue

Parameters:
PropertyTypeDescription
propertyNameStringName of the property to be retrieved.

Returns:
TypeDescription
Any TypeValue of the specified property


Retrieves a particular property from the current game object.

JavaScript:
var curScore = Game.GetValue("Score");

SetValue

Parameters:
PropertyTypeDescription
propertyNameStringName of the property to be set.
valueAny typeValue of the property.


Set a particular property on the current game object.

JavaScript:
Game.SetValue("Score", Game.GetValue("Score") + 10);

PlayAudio

Parameters:
PropertyTypeDescription
urlStringAddress containing the audio file
repeatbooleanif true, audio repeats indefinitely.


Plays the specified WMA or MP3 file.

SpawnActor

Parameters:
PropertyTypeDescription
paramspropertyBagName of the property to be set.

Returns:
TypeDescription
ActorThe spawned actor.

Params property bag
PropertyTypeDescription
actorStringName of the actor type you would like to spawn
xnumber (optional)x location of the spawned actor
ynumber (optional)y location of the spawned actor
effectproperty bagcontains 2 boolean flags, scale and fade.
Spawns the an actor specified by the parameter onto the current scene.

ChangeScene

Parameters:
PropertyTypeDescription
newSceneNameStringThe name of the scene to change to.


Changes the scene to the one specified.

Edit

Game 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)

Edit

Scene 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).


Edit

Scene Objects Methods

GetValue

Parameters:
PropertyTypeDescription
propertyNameStringName of the property to be retrieved.

Returns:
TypeDescription
Any TypeValue of the specified property

Retrieves a particular property from the scene.

JavaScript:
var curScene = Game.CurrentScene;
var curSceneX= curScene .GetValue("X");

SetValue

Parameters:
PropertyTypeDescription
propertyNameStringName of the property to be set.
valueAny typeValue of the property.


Set a particular property on the scene.

JavaScript:
var curScene = Game.CurrentScene;
curScene.SetValue("X", 5);



GetActors

Parameters:
PropertyTypeDescription
ActorsArray of StringList of actor names to retrieve

Returns:
TypeDescription
List of ActorsList 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:
PropertyTypeDescription
ActorStringactor name to retrieve

Returns:
TypeDescription
Actorretrieved 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");


RemoveEventListener


AddEventListener


Edit

Actor Objects


Edit

Actor Objects Methods

GetValue

Parameters:
PropertyTypeDescription
propertyNameStringName of the property to be retrieved.

Returns:
TypeDescription
Any TypeValue 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:
PropertyTypeDescription
propertyNameStringName of the property to be set.
valueAny typeValue of the property.


Set a particular property on the actor.

JavaScript:
var curActor = Game.CurrentScene.GetActor("Spaceship 1");
curActor.SetValue("X", 5);



GetCenter

Returns:
TypeDescription
PointLocation of the center point of the actor relative to the scene. Contains the X and Y component.

Retrieves the center point of the actor

JavaScript:
var curActor = Game.CurrentScene.GetActor("Spaceship 1");
var curActorX= curActor.GetCenter().X;

GetCenterY

Returns:
TypeDescription
IntegerLocation of the center point, the Y value, of the actor relative to the scene.

Retrieves the Y value of the center point of the actor

JavaScript:
var curActor = Game.CurrentScene.GetActor("Spaceship 1");
var curActorY= curActor.GetCenterY();

GetCenterX

Returns:
TypeDescription
IntegerLocation of the center point, the X value, of the actor relative to the scene.

Retrieves the X value of the center point of the actor

JavaScript:
var curActor = Game.CurrentScene.GetActor("Spaceship 1");
var curActorX= curActor.GetCenterX();

GetPosition

Returns:
TypeDescription
PointLocation 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 actor

JavaScript:
var curActor = Game.CurrentScene.GetActor("Spaceship 1");
var curActorX= curActor.GetPosition().X;

GetVisualRoot

Returns:
TypeDescription
Silverlight ElementRoot canvas of the actor

Retrieves the root canvas of the actor


AddEventListener


RemoveEventListener


ChangeState

Parameters:
PropertyTypeDescription
newStateNameStringThe name of the stateto change to.


Changes the state to the one specified.

IsOffScene

Returns:
TypeDescription
Booleantrue if the actor is currently off-screen


Check if the actor is currently offscreen.

Remove

Parameters:
PropertyTypeDescription
effectproperty bagcontains 2 boolean flags, scale and fadein.


Removes the actor from the scene with the specified effect

currentState

Object:
PropertyTypeDescription
namestringcontains the actuale name of the state.
widthintegerContains the width of the Actor in this state.
heightintegerContains the height of the Actor in this state.
isSolidbooleanReturns true or false wether the Actor is an solid.
xamlstringReturns the complete XAML value for this state.
egdesuknownunknown


Returns an object with the above properties.

JavaScript:
var curActor = Game.CurrentScene.GetActor("Spaceship 1");
var currentState = curActor.currentState.name;

Privacy. Terms of Use. Trademarks.
ScrewTurn Wiki version 2.0.22. Some of the icons created by FamFamFam.