Scripts / Help Please: Timed duration of a Sprite

Author
Message
Isagabe
10
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 30th Dec 2015 13:59
Greetings guys
I am trying to get a bit of code running with little success. I want the sprite to show for a few seconds then disappear. I have it attached to an arbitrary entity, set to Static: No and Always Active. SetSpriteDuration() does not seem to be a command. My effort below; I get the sprite to show up but it will not disappear after the stipulated time.

Thanks and wishing you all a prosperous 2016.

smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 30th Dec 2015 19:46


im not sure why you have it set to 100,100 for position though, technically that should be just off the screen?
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
Isagabe
10
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 30th Dec 2015 20:14
Thank you smallg. Much appreciated. I was so far off track that it is scary. Will try your code as soon as I get to my laptop. On my screen at 1920x1080 resolution (100,100) the sprite appears on the top left of the screen. Which is where I want it but to be honest I found those by trial and error. Mostly error to be honest. And now more confused than ever but thank you.
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 30th Dec 2015 20:35 Edited at: 31st Dec 2015 08:01
I thought 100, 100 was bottom right, or is it the opposite way round for sprites compared to text panes?
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 30th Dec 2015 21:39
sprites work in % of the screen so 0,0 is top left and 100,100 is bottom right of the screen
it depends on where the offset of the image is as well as the size of the sprite though as to where the image will appear (default is top left corner of the image) - in your case it sounds like one of those is off (not technically a problem but i would probably set the size to 100 and then position it at 0,0 just to be sure it'll work for all resolutions as im not sure how it works if the size isn't set)
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
wermer
9
Years of Service
User Offline
Joined: 18th Sep 2015
Location:
Posted: 30th Dec 2015 23:49 Edited at: 30th Dec 2015 23:51
small's script wont work as it is. It calls the non-existent function "DestroySprite".

He is correct about the coordinate system. You're seeing your sprite in the top left because it's initial coordinates are '0 , 0' and "SetSpritePosition ( locationSprite , 100 , 100 )" is never being called. You say your script is attached to an arbitrary entity, set to Static: No and Always Active, then trying to trigger an event on 'plrinzone'. I think you should use a zone, such as a TriggerZone, or if you must use an entity trigger your event using GetPlayerDistance.

I'm sure you can do this with timers, but for me this is easier:
Windows 10 Home 64-bit / Intel i5 2500k @ 4.4Ghz + Asetek 510LC / Intel DP67DE / Intel 530 Series 240GB SSD / 12GB Kingston KVR 1333 / XFX Radeon R9 285 / Corsair TX 650 / Antec 300
PM
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 31st Dec 2015 00:26
ah yes good spot on him not using a zone, i just edited his original script but that would make more sense as to why it's appearing in the "expected" place
DestroySprite(locationSprite) should be DeleteSprite(locationSprite) - i still get mistakes with my coding even after all this time, but it's confusing when the commands are clearly named/created by different people, i.e. Hide for images, Delete for sprites but Destroy for entitys..... or SetPosition and SetEntityHealth (both of which only work for entitys so why does one specify entity but not the other?).. etc.. i wont even mention the AI commands
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
Isagabe
10
Years of Service
User Offline
Joined: 12th Sep 2014
Location:
Posted: 31st Dec 2015 08:43
Thanks guys. Much appreciated.

I added script to an entity as opposed to a zone ( getplayerdistance etc) because I want it activated throughout the level. If my layman's understanding of this is correct, if a zone is used; once player distance is lost then code will not play. Correct? Which is why I opted for the always active entity. But obviously I am not understanding this clearly.

Anyway, when the code is finally complete and assuming I get it to work, the script will call different sprites, at different intervals, in different screen coordinates, as player moves through level. I will post my feeble attempt as soon I work it all out but your input has certainly helped me understand this process a little better. Thank you.
Happy New year.

Login to post a reply

Server time is: 2025-01-01 05:20:20
Your offset time is: 2025-01-01 05:20:20