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

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

Moderator: Userbase Moderators

Chilly14
Snifit
Snifit
Posts: 236
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

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

Postby Chilly14 » Thu Jan 02, 2020 12:16 pm

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.

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

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

Postby Emral » Thu Jan 02, 2020 1:00 pm

around line 304 in luna.lua of the mario challenge hub level

Chilly14
Snifit
Snifit
Posts: 236
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

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

Postby Chilly14 » Thu Jan 02, 2020 1:19 pm

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

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9865
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

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

Postby Emral » Thu Jan 02, 2020 1:35 pm

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.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari