Back

CreateBackground

JS Py
Hello World
Content:
- Properties
- Methods

Creates a background.

bck = gfx.CreateBackground( file, options ) → game object: Background

Example - Scroll

cfg.Game;

function OnLoad()
{
    sky = gfx.CreateBackground( "/Sys/Img/Sky.jpg", "stretch" );
}

function OnReady()
{
    gfx.AddBackground( sky );
    gfx.Play();
}

function OnAnimate(t,dt)
{
    sky.Scroll(-dt/1000, 0);
}
# cfg.Game

def OnLoad():
    global sky
    sky = gfx.CreateBackground("/Sys/Img/Sky.jpg", "stretch")

def OnReady():
    gfx.AddBackground(sky)
    gfx.Play()

def OnAnimate(t, dt):
    sky.Scroll(-dt/1000, 0)
    Copy     Copy All       Run      

Properties

The following properties are available on the Background object:

loadedBoolean

Methods

The following methods are available on the Background object:

Scroll( x, y )
Number
String: path to file ( “/absolute/...” or “relative/...” )
String: comma “,” separated: “stretch”
bck.loaded
Indicates if the background is ready for use
bck.Scroll
Scrolls the background by a given value