SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Editing > Editing Help

Reply
 
Thread Tools Search this Thread
Old 05-25-2018   #1
TSDude
Lack of tea
 
TSDude's Avatar
Default Another Custom HUD Question

EDIT: I decided to move on from this idea for the time being, mainly due to the graphics and onscreen effects I'm working with not really fitting the style of the levels I'm making.

If any of you still have some advice to the old post hidden in the spoiler below, then feel free to respond.

Spoiler: Old post
So...
It's been a long time since I touched anything lua related.

Lately I've been trying to create a custom stage title HUD.

The aim was to make my custom stage title appear instead of the original srb2 stage titles, while also making sure that they slide on and off the screen when you just start a level.

I attempted this using my old "starpost-item-giving" lua file as a template.

The problem that I had bumped into however, was that I couldn't figure out how to make the custom stage title slide off the screen.

Imagine this but instead of fading out, the title and its background would keep moving to the right, until it is no longer on screen.

Here's the current code I have for this:
Spoiler:
Code:
local fonttimer = 0
local fontbacktimer = 0
local frontxpos = 70
local backxpos = 50

//Timer for stage title HUD in the front
local function startFontTimer()
	for player in players.iterate
		if player.fonttimer != nil and player.fonttimer > 0
			player.fonttimer = $1 - 1
			if player.fonttimer < TICRATE
				player.frontxpos = $1 + 1
				if player.frontxpos > 200
					player.fonttimer = 0
				end
			end
		end
	end
end

//Timer for stage title background HUD in the back
local function startFontBacktimer()
	for player in players.iterate
		if player.fontbacktimer != nil and player.fontbacktimer > 0
			player.fontbacktimer = $1 - 1
			if player.fontbacktimer < TICRATE 
				player.backxpos = $1 + 1
				if player.backxpos > 200
					player.fontbacktimer = 0
				end
			end
		end
	end
end

local function LevelSpawn(player)
	player.fonttimer = 2*TICRATE
	player.fontappear = "TESTFNT" //Name of stage title front image
	player.frontxpos = 0
	player.fontbacktimer = 2*TICRATE
	player.fontbackappear = "DBLOCK" //Name of stage title background image
	player.backxpos = 0
end

local function fonty(v, stplyr)
	if stplyr.fonttimer != nil and stplyr.fonttimer > 0
		local fontpatch = (v.cachePatch(stplyr.fontappear))
			v.draw(frontxpos, 82, fontpatch)
	end
end

local function funty(v, stplyr)
	if stplyr.fontbacktimer != nil and stplyr.fontbacktimer > 0
		local fontbackpatch = (v.cachePatch(stplyr.fontbackappear))
			v.draw(backxpos, 80, fontbackpatch)
	end
end
hud.add(funty) //Place before "fonty" so that the background isn't seen in front of the stage title
hud.add(fonty)
hud.disable("stagetitle")
addHook ("ThinkFrame", startFontTimer)
addHook ("ThinkFrame", startFontBacktimer)
addHook ("PlayerSpawn", LevelSpawn)


I'm pretty much lost here on how to mix the timer scripting with a script for sliding the HUD.
__________________
*snip*

Last edited by TSDude; 05-27-2018 at 02:31 PM. Reason: Change of plans
TSDude is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:23 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.