Graphics.loadImage

From Moondust Wiki
Revision as of 11:39, 18 August 2017 by Yingchun Soul (talk | contribs)
Jump to navigation Jump to search

This function is used to load an image into the resource memory of SMBX. This image can be displayed with other functions in the Graphics category.

Usage

First, you need an image to use. The image must be in the .png format, or it may not display correctly. The image can have true transparency; a mask image is not required. To use this function, you must set a variable that contains it:

function onStart()
  img = Graphics.loadImage("test.png")
end

This loads the image "test.png" into the resource memory of SMBX. Note that this doesn't cause the image to appear, but it makes it available to be called in other functions.

In a function for showing the image, set the variable you used as the argument for "LuaImageResource":

function onStart()
  img = Graphics.loadImage("test.png")
  Graphics.placeSprite(1, img, 0, 0)
end

This will load "test.png" on the screen at position [0,0] (the top left corner).