Scripts / Sprites trouble

Author
Message
GubbyBlips
2
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 19th Sep 2021 04:27
Alright.
Took a while to get some text in front of a set of sprites...
Now want to get text behind a different set of sprites. Isn't cooperating. Any ideas?
have;
SetSpriteDepth ( c_Sprite, 100 )
PasteSpritePosition ( c_Sprite, 45, 30 )
Text(48, 35, 3, "/ / /" )
The text is on top with this.
PM
smallg
Community Leader
15
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 19th Sep 2021 09:56
PasteSpritePostition - text always infront
SetSpritePosition - text always behind
depth is only for sprite to sprite layering
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
GubbyBlips
2
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 19th Sep 2021 21:54
Thanks for that info smallg, that's great to know.
Is it necessary to call PasteSpritePostition or SetSpritePosition every frame inside your main.lua?
Right now I'm just moving them back and forth off screen (to erase) or back to position as needed.
Or could calling them every time even if they are stationary use up memory?
PM
smallg
Community Leader
15
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 19th Sep 2021 22:37 Edited at: 19th Sep 2021 22:39
PasteSpritePosition - every frame
SetSpritePosition - only when it changes however it won't recreate the sprite etc so calling it every frame is only using a tiny bit of processing time
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
AmenMoses
GameGuru Master
5
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 20th Sep 2021 18:28
With PasteSprite the 'depth' of the sprite depends on the order of the calls, so if I said:
PasteSprite( sprite1 )
PasteSprite( sprite2 )
PasteSprite( sprite3 )

Then sprite1 would be on the bottom, sprite 2 pasted on top of 1 and sprite 3 pasted on top of sprites 2 & 1.

With SetSpritePosition otoh the 'depth' is determined by SetSpriteDepth.
Been there, done that, got all the T-Shirts!
PM
GubbyBlips
2
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 20th Sep 2021 22:43
@AM
Glad you mentioned this, as I was getting frustrated and about to make a gripe!
Doesn't seem intuitive to be able to accomplish both stacked sprites in a logical
order and Text in front or behind when necessary...
As constituted, I was getting various hit and miss results.
Well as you mentioned it, that sounds like it should cover the needs.
Will be just look @ it and see. (Running a historic GG version) -- so - there's that...
PM
GubbyBlips
2
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 21st Sep 2021 00:49 Edited at: 21st Sep 2021 18:55
Question:
SetSpriteColor ( mySprite , red , green, blue, alpha )
How would you go from the default colors to a selected color and then back to
the default image color...? Will be messing with this, but not sure how to proceed...
(sprite, 0,0,0,0)?
(sprite, 100,100,100,100)?
--------------------------------------------------
1 hrs lader mini tutorial;
Those color and alpha values go from 0-256 in line with TextColor settings.
So all 256 should be normal again.

Correction... as AmenMoses points out below;
Stay clear of exceeding the 255 boundary (I should know) throws a runtime error
and hard reset required. 256 is the spirit of the color, but not the letter of the law!
PM
AmenMoses
GameGuru Master
5
Years of Service
User Offline
Joined: 20th Feb 2016
Location: Portsmouth, England
Posted: 21st Sep 2021 12:40
To eradicate the colour settings you would need to delete the sprite and re-create it I think.

You could try SetSpriteColor( sprite, -1, -1, -1, -1 ) though.

And colour/alpha valid values for sprites are 0-255 I believe.
Been there, done that, got all the T-Shirts!
PM
GubbyBlips
2
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 21st Sep 2021 18:58
Yes, corrected the numero, and that's important to avoid a restart--
especially if you're working on a MAP!
PM

Login to post a reply

Server time is: 2021-11-27 20:16:30
Your offset time is: 2021-11-27 20:16:30