Scripts / How do I display text in front of Sprites?

Author
Message
SounDesign
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 4th Mar 2015
Location:
Posted: 5th Feb 2016 09:54 Edited at: 5th Feb 2016 09:58
So I created two scripts, one to set up the HUD 'background' which shouldn't need to be updated much hence inserting the 'background image' here.
Then the second which is the regularly updated actual scores.

BUT although I set the image to depth of the sprite to 100 the text still displays behind it? (I know it's commented out below, but that was the last time I 'trialed' something else...)

Is there a way to bring it in front of the sprites?

And the text disappears when you go in zoom mode - the sprites stick around. Can I make the text 'sticky' too?

AND; as I type, I am wondering if I should combine the two scripts into one anyway..

SETUP SCRIPT:

-- LUA Script - precede every function and global member with lowercase name of script + '_main'

g_score_heads = 0
g_score_kills = 0
g_score_cash = 0
g_score_xp = 0

function _01stored_init(e)

hdkillImageBack = LoadImage ( "scriptbank\\soundesign\\images\\hdkill.png" )
hdkillSprite = CreateSprite (hdkillImageBack)
--setSpriteDepth (hdkillSprite, 100)

xpcashImageBack = LoadImage ( "scriptbank\\soundesign\\images\\xpcash.png" )
xpcashSprite = CreateSprite (xpcashImageBack)
--setSpriteDepth (xpcashSprite, 100)

end


function _01stored_main(e)

SetSpriteSize ( hdkillSprite , -1 , -1 )
SetSpritePosition ( hdkillSprite , 1 , 0 )

SetSpriteSize ( xpcashSprite , -1 , -1 )
SetSpritePosition ( xpcashSprite , 83 , 0 )

end

SCORE TRACKING SCRIPT:

-- LUA Script - precede every function and global member with lowercase name of script + '_main'

g_score_heads = 0
g_score_kills = 0
g_score_cash = 0
g_score_xp = 0

function _02scores_init(e)

end


function _02scores_main(e)

TextCenterOnX (9,3,4,g_score_heads)
TextCenterOnX (9,9,4,g_score_kills)

TextCenterOnX (91,3,4,g_score_xp)
TextCenterOnX (91,9,4,g_score_cash)

end



OOOOOPS!!!!

just noticed I set up the globals twice!!! still seems to work for now in my test game, but I'm gonna smack it the hell out now...
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 5th Feb 2016 11:12
it should be added for next build... or so i was told when i asked about it
the zoom is likely something you'll need to check and workaround yourself for now, maybe it'd be easier just create another sprite that copies the existing zoom screen and then place that on top rather than worrying about checking and hiding any custom HUD images.
or maybe there's a way to edit the zoom screen image directly and make the portions you require transparent?
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
SounDesign
GameGuru TGC Backer
9
Years of Service
User Offline
Joined: 4th Mar 2015
Location:
Posted: 5th Feb 2016 11:35 Edited at: 5th Feb 2016 12:02
Oh OK, so perhaps they'll 'merge' AGK and GG ultimately (I LOOOOOVE AGK!) then we can assign anything to 'layers'..

As it stands I'm not too stressed about text (which should be white) appearing grey, just hoping for an easy answer!!!

The zoom thing IF I study what you said I could perhaps make it work, but right now it makes my head swing (OK so I was up till 2 this morning getting some other things right - then up at 6 to take daughter to school).

Think I'll go get some catchup sleep now, thanks anyway oh great one! - If I ever make my millions with my CoD lookalike ( I recognise I owe you a share, for without your scripts I wouldda got nowhere!!!!

PS:

I found a way to extract kills and headshots (that SEEMS to work) from ai-soldier script. but now I have to copy and modify all the ai scripts and they're er not exactly very friendly, some seem VERY different. Do you know if there is a 'secret' variable somewhere I could use that would make this easier, OR, is it also up to us to keep on keepin on with these workarounds????

PPS:

Now that's weird. Just testing quickly, noticed something I didn't see before. The text also seems to disappear every now and again then comes back. I haven't been able to confirm if it is time based, action based etc. currently seems just random...any ideas?
I'm wondering about shuffling - sprites above the text as headers rather than overlays...shame was trying to keep the GG look

Cheers and thanks again...Phil
PM
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 5th Feb 2016 12:43
i would guess the script with the prompt is reaching it's cut-off range so making it always active should fix it.

for headshots and kill count you would need to do that manually but shouldn't take too long, there's already headshot code to use as a guide (or simply add a variable to increment there)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11

Login to post a reply

Server time is: 2024-05-03 14:33:16
Your offset time is: 2024-05-03 14:33:16