SRB2 Message Board  

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

Thread Tools Search this Thread
Old 05-25-2018   #1
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
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:
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

//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

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

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

local function funty(v, stplyr)
	if stplyr.fontbacktimer != nil and stplyr.fontbacktimer > 0
		local fontbackpatch = (v.cachePatch(stplyr.fontbackappear))
			v.draw(backxpos, 80, fontbackpatch)
hud.add(funty) //Place before "fonty" so that the background isn't seen in front of the stage title
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.

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

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 02:38 PM.

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