Page 1 of 1

No transparency in custom backgrounds

Posted: Sat Aug 18, 2018 5:52 pm
by Alancron
Hi, i've been dealing with a problem in smbx2's editor: I made a custom graphic in background-23, and it looks fine on the editor, but when i test the level it disappears.

Image

Image

Thanks in advance. :mrgreen:

Re: No transparency in custom backgrounds

Posted: Sat Aug 18, 2018 6:21 pm
by Emral
What's actually happening is that only the transparent area in the top left corner is being drawn.
As of Beta 3, BGOs don't automatically resize.
I wrote some code which should take care of that though:

Code: Select all

local replacedBGOs = {1,2,3,4,5,6,7,21,22,27,28,29,31,32,37,94,97,99,101,102,108,109,110,111,112,113,114,117,119,121,122,123,124,131,132,133,147,150,151,152,153}

local bgoImg = {}

for k,v in ipairs(replacedBGOs) do
	bgoImg[v] = Graphics.loadImage("background-"..v..".png")
end

local cam = Camera.get()[1]

function onDraw()
	do
		local cX = cam.x
		local cY = cam.y
		for k,v in ipairs(BGO.getIntersecting(cX - 200, cY - 100, cX + 1000, cY + 800)) do
			if bgoImg[v.id] then
				Graphics.drawImageToSceneWP(bgoImg[v.id], v.x, v.y, -75)
			end
		end
	end
end
https://hastebin.com/iboyuzubik.bash
Put this into a file called lunadll.lua inside your level folder (folder where your custom graphics are). Then all you have to do is change the IDs in the replacedBGOs list. You can take all of them out for a start, I only left them in as an example.