Page 1 of 1

How do I make background stuff move up and down like the clouds in the Mario Challenge hub?

Posted: Thu Jan 02, 2020 12:16 pm
by Chilly14
If you don't know what I mean, take a look:
Image
See those clouds the ship is above? I want my background elements to move up and down the exact same way those clouds do.

Re: How do I make background stuff move up and down like the clouds in the Mario Challenge hub?

Posted: Thu Jan 02, 2020 1:00 pm
by Emral
around line 304 in luna.lua of the mario challenge hub level

Re: How do I make background stuff move up and down like the clouds in the Mario Challenge hub?

Posted: Thu Jan 02, 2020 1:19 pm
by Chilly14
This happens:
Image
Code:

Code: Select all

local paralx = API.load("paralx2")

local fade = 1

Block.config[751].ceilingslope = 1
Block.config[752].ceilingslope = -1
Block.config[755].floorslope = -1
Block.config[756].floorslope = 1

function onTick()
	fade = fade - 0.01

	for k,v in ipairs(bgObj:get()) do
		if(v.name:match("^clouds%d+$")) then
			v.speedY = 0.8*math.sin(lunatime.tick()*0.02*k);
		end
	end
end

function onDraw()
	Graphics.drawScreen{color = Color.black .. fade, priority = 5}
end

Re: How do I make background stuff move up and down like the clouds in the Mario Challenge hub?

Posted: Thu Jan 02, 2020 1:35 pm
by Emral
You didn't copy the piece of code where the variable is initialized, so of course it's nil.
bgObj is probably initialized in an onLoadSection event and refers to the parallaxing background of the section.