![]() |
Forum Index : Microcontroller and PC projects : Needed: Function to tell if a sprite is showing
Author | Message | ||||
William Leue Guru ![]() Joined: 03/07/2020 Location: United StatesPosts: 405 |
I want to write a function that simply loops through all the sprites in an app and hides them. However, I quickly found that if a sprite is not visible, the SPRITE HIDE command throws an error. Looking through the 5.05.05 documentation, I don't see a function that could be called to get this info. Maybe Peter might consider adding it to 5.05.06, something like SPRITE(D,[#]n) Returns a 1 if the sprite is visible, 0 if not. I guess another way to implement this idea is just to have SPRITE HIDE do nothing if the sprite is already hidden or not visible for some other reason. -Bill |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
SPRITE(X, [#]n) Returns the X-coordinate of sprite n. This function is only active when the sprite is currently displayed (active). Returns 10000 otherwise. |
||||
William Leue Guru ![]() Joined: 03/07/2020 Location: United StatesPosts: 405 |
D'oh! I should learn to read ALL the text in the manual! Thanks, Peter! -Bill |
||||
William Leue Guru ![]() Joined: 03/07/2020 Location: United StatesPosts: 405 |
Well, hmmm. Even though I use SPRITE(X,n) <> 10000 to test whether the nth sprite is visible, I still get the 'ERROR: not showing' error. I am still on 5.05.03. Is it possible the SPRITE(X,n) function is buggy in that version? -Bill |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10310 |
Works on 5.05.06b15. Can't remember when/if fixed |
||||
vegipete![]() Guru ![]() Joined: 29/01/2013 Location: CanadaPosts: 1132 |
I too get way too many 'ERROR: not showing' messages with sprites. So much so that I've taken to parking all my sprites at (MM.HRES-1,MM.VRES-1) and never hiding them. If SPRITE HIDE can't hide hidden sprites, perhaps I'll try with an ON ERROR SKIP statement just before. ============== Didn't SPRITE(X,n) return -1 for a while for hidden sprites? Edited 2020-10-03 02:46 by vegipete Visit Vegipete's *Mite Library for cool programs. |
||||
capsikin Guru ![]() Joined: 30/06/2020 Location: AustraliaPosts: 341 |
Yes. I suggest you don't try to use the buggy output for checking when the sprite is active, or it will stop working on newer fixed firmware. If you want code that works in older firmware, you can check SPRITE(L, [#]n) and compare it to -1. It is -1 if the sprite is not active (as is the buggy SPRITE(X,n)). Works on 5.05.06b15. Can't remember when/if fixed I know it was fixed some time after 5.05.04. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |