Class Index | File Index

Classes


Class SceneContent

SceneContent represents any object which can be placed in the "content" field of any group node of a Scene. This object defines the methods and attributes, which are expected to be implemented by any scene content.
Defined in: SceneContent.js.

// Creates a new SceneContent object.
var myContent = SceneContent({x: 10, y: 10, w: 100, h: 100, name: "my_content"});
// Your content can be retrieved from the scene using its name.
myScene["my content"]
Class Summary
Constructor Attributes Constructor Name and Description
 
SceneContent(_details)
Field Summary
Field Attributes Field Name and Description
 
The public details field should refer to the original object passed in to the creation function.
Method Summary
Method Attributes Method Name and Description
 
draw(_context)
The draw function is responsible for drawing this content to the given canvas context.
 
extend(_child)
This extends the provided child function with this instance.
 
The getBounds function should return the location and size of this content relative to it's parent.
 
Gets the name of this SceneContent as it was passed in the original _details object.
 
The getParent function returns the parent of this content.
 
The getScene function returns the scene this content belongs to.
 
The getStage function returns the stage this content belongs to.
 
isActive Is this content currently active.
 
isVisible Is this content currently visible.
 
load(_scene, _parent)
The load function gets called after all the stage objects and content have been initialized.
 
loadBase(_scene, _parent)
Sets the scene, parent and stage for this content.
 
moveBy(_distance)
The moveBy function moves this content's relative x, y position by the the given distances.
 
moveTo(_point)
The moveTo function moves this content's relative x, y position to the values provided in the point object.
 
setActive(_active)
setActive Sets this content's active status flag.
 
setSize(_dimension)
The setSize function sets this content's width and height.
 
setVisible(_visible)
setVisible Sets this content's visible status flag.
 
update(_runtime)
The update function is called after the load function has been called and before the draw function is called.
 
updateBase(_runtime)
The updateBase function should be called by subclasses overriding the update function.
Class Detail
SceneContent(_details)

Author: Eric Berry.
Parameters:
_details
All SceneContent takes a JSON object in it's factory function with the following properties: Expected but not required properties:
Property Required Default
active no true
h no 0
visible no true
w no 0
x no 0
y no 0
name no
This is a base set of properties. Any object that extends SceneContent should be expected to handle this set of properties. Some exceptions include the Graphic object which sets the width and height properties after the image has been loaded. The Sound object, which doesn't have any use of coordinates or size. And Groups, their width and height attributes are based on their content.
Field Detail
details
The public details field should refer to the original object passed in to the creation function. Users should always be able to attach their own details to any scene content object and retrieve it again using the public details field.
Method Detail
draw(_context)
The draw function is responsible for drawing this content to the given canvas context. It is called after the update function.
Parameters:
_context
The canvas context this content should be drawn to.

extend(_child)
This extends the provided child function with this instance.
Parameters:
_child
The child function to be extended.

{Bounds} getBounds()
The getBounds function should return the location and size of this content relative to it's parent.
var myGraphic = Graphic({ x: 13, y: 13, url: "./images/ball.png" });
var myGrp = Group({ x: 10, y: 10, content: [myGraphic] });
alert(myGraphic.getBounds().x); // alerts 13

Returns:
{Bounds} with 4 fields, x, y, w, and h.

getName()
Gets the name of this SceneContent as it was passed in the original _details object.
Returns:
The name of this SceneContent

{SceneContent|Scene} getParent()
The getParent function returns the parent of this content. This usually returns another SceneContent object, except when this object is the first child of the Scene object. In which case, the Scene itself is returned.
Returns:
{SceneContent|Scene} The parent of this content.

{Scene} getScene()
The getScene function returns the scene this content belongs to. The scene is passed in to the load function.
Returns:
{Scene} The Scene Object this content belongs to.

{Stage} getStage()
The getStage function returns the stage this content belongs to. The stage can originally be retrieved by the Scene object which is passed in to the load function.
Returns:
{Stage} The Stage Object this content belongs to.

isActive()
isActive Is this content currently active. This field tells the Scene that this content needs to be updated and drawn. If content is not active then it will not be updated or drawn.
Returns:
true if this content is active, false otherwise.

isVisible()
isVisible Is this content currently visible. This field tells the Scene that this content needs to be drawn. If the content is not visible then it will not be drawn.
Returns:
true if this content is visible, false otherwise.

load(_scene, _parent)
The load function gets called after all the stage objects and content have been initialized. It's only called once when the Scene's load method is called.
Parameters:
{Scene} _scene
The Scene this content belongs to.
{SceneContent|Scene} _parent
The parent of this content.

loadBase(_scene, _parent)
Sets the scene, parent and stage for this content. Also adds this object to the scene by name.
Parameters:
_scene
_parent

moveBy(_distance)
The moveBy function moves this content's relative x, y position by the the given distances. This is equivalent to an instant translation, vs. the use of a Translation Transform node. The function should work on partial data, and a lack of data should signify non-action.
var myImage = Graphic({ x: 10, y: 10, url: "./images/ball.png" });
alert(myImage.getBounds().x); // alerts 10
myImage.moveBy({x: 5});
alert(myImage.getBounds().x); // alerts 15

Parameters:
{Number} _distance
A Distance object with two fields, x, and y.

moveTo(_point)
The moveTo function moves this content's relative x, y position to the values provided in the point object. The function should work on partial data, and a lack of data should signify non-action.
var myImage = Graphic({ x: 10, y: 10, url: "./images/ball.png" });
alert(myImage.getBounds().x); // alerts 10
myImage.moveTo({x: 15});
alert(myImage.getBounds().x); // alerts 15

Parameters:
{Point} _point
Point object with two fields, x, and y.

setActive(_active)
setActive Sets this content's active status flag.
Parameters:
{Boolean} _active
true or false

setSize(_dimension)
The setSize function sets this content's width and height. The function should work on partial data, and a lack of data should signify non-action.
// Only updates the width of the SceneContent.
var rect = Rectangle({ x: 10, y: 10, w: 10, h: 10 });
rect.setSize({w: 15 });
alert(rect.getBounds().w == 15) // alerts true.

Parameters:
{Bounds} _dimension
A Dimension object with two fields, w, and h.

setVisible(_visible)
setVisible Sets this content's visible status flag.
Parameters:
{Boolean} _visible
true or false

update(_runtime)
The update function is called after the load function has been called and before the draw function is called. It's called repeatedly with the total time passed since the Scene's load time.
Parameters:
{Number} _runtime
The total time passed since the Scene's load time.

updateBase(_runtime)
The updateBase function should be called by subclasses overriding the update function. This function automatically hides SceneContent if it goes outside the boundaries of the stage. This method can be extended by supplying an update function in the initialization data.
// Supplying your own update function
Graphic({
   x: 10, y: 10, url: "./images/ball.png",
   update: function(_runtime) {
      // do something
   }
})
Parameters:
{Number} _runtime
The total time passed since the Scene's load time.

Documentation generated by JsDoc Toolkit 2.3.0 on Fri Oct 30 2009 09:09:10 GMT-0700 (PDT)