Help with loading an image

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

LunarCatUSA
Monty Mole
Monty Mole
Posts: 115
Joined: Sat Mar 06, 2021 9:56 am
Flair: Soda-Butler

Help with loading an image

Postby LunarCatUSA » Wed May 19, 2021 6:02 pm

So I want to display a 256 by 256 PNG image on the screen during gameplay.

Code: Select all

if scenetimer >= 3705 then
		function onDraw()
			Graphics.draw{
				type = RTYPE_IMAGE,
				image = title,
				x = camX,
				y = camY,
				priority = 0,
				sceneCoords = true
			}
		end
	end
Note: The scenetimer is just to display the image at the right time, title is the 256x256 PNG I want to show, and x and y are defined as player camera positions.
So I run the script and I get this error message:
Image
Anyone know any way I can correct this?

Added in 5 minutes 59 seconds:
Wait, does the image need to be in the folder of the respective level's script?

Hoeloe
Phanto
Phanto
Posts: 1465
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Help with loading an image

Postby Hoeloe » Wed May 19, 2021 8:14 pm

You never loaded the title image, nor defined camX and camY. You need to use Graphics.loadImage to load the image you want, which will be relative to your level folder unless you also run the path through Misc.resolveFile.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari