SFramework extends upon some of the capability built into CraftStudio. The GameObject has gained a few new functions.
GameObject.spriteRenderer
GameObject.physics
Returns a reference to the SpriteRenderer behavior of the object
local mySpriteRenderer = self.gameObject:GetSpriteRenderer()
Creates a new SpriteRenderer
sprite
- CS Asset
(optional) a Font asset to set the default sprite to
local mySpriteRendererEmpty = self.gameObject:CreateSpriteRenderer()
local mySpriteRenderer = self.gameObject:CreateSpriteRenderer(CS.FindAsset("Sprites/Sample/SampleSprite", "Font"))
Returns a reference to the Physics component of the object
local myPhysics = self.gameObject:GetPhysics()
Adds a Physics component with default values to the object and returns a reference
colliderType
- string
(optional) the colliderType of the collider - defaults to BOX
width
- number
(optional) the width of the collider - defaults to 1
height
- number
(optional) the height of the collider - defaults to 1
mass
- number
(optional) the mass of the object - defaults to 1
static
- bool
(optional) whether or not the object is static - defaults to false
bounciness
- number
(optional) the bounciness of the object - defaults to 0
local myDefaultPhysics = self.gameObject:AddPhysics()
local myCustomPhysics self.gameObject:AddPhysics('BOX', 1, 10, 1, false, .5)