Background
Setting the background image for B4GL.
Dim backgroundImage, bgsprite
Create the variable
backgroundImage = LoadTexture("Background.jpg")
bgSprite = NewSprite(backgroundImage)
Load the texture, then create a new sprite named bgSprite with the texture backgroundImage.
SprSetPos(320,240)
SprSetSize(640,480)
Set the position and size. 640x480 is the window size. 320,240 is the center because the sprite's origin is its center.
SprSetZOrder(3)
Set the ZOrder to 3. Whatever has a ZOrder of less than 3 will be drawn on top of the background.
SprSetColor(0,255,0)
DrawText()
This changes the background's colour. It uses RGB (Red, Green, Blue) values, with a max value of 1 for each colour (for less of a colour, use a decimal number e.g. 0.5). So 0,1,0 is blue, 1,0,0 is red, and 0,0,1 is green.
Then, DrawText() updates the screen so we can see the change in the background's colour.
Complete code:
Dim backgroundImage
backgroundImage = LoadTexture("Background.jpg")
bgSprite = NewSprite(backgroundImage)
SprSetPos(320,240)
SprSetSize(640, 480)
SprSetZOrder(3)
SprSetColor(0,255,0)
DrawText()
page revision: 14, last edited: 25 Feb 2021 04:10