Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:11 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

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 States
Posts: 405
Posted: 03:19pm 02 Oct 2020
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10310
Posted: 03:22pm 02 Oct 2020
Copy link to clipboard 
Print this post

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 States
Posts: 405
Posted: 03:26pm 02 Oct 2020
Copy link to clipboard 
Print this post

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 States
Posts: 405
Posted: 03:32pm 02 Oct 2020
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10310
Posted: 03:36pm 02 Oct 2020
Copy link to clipboard 
Print this post

  Quote  I am still on 5.05.03. Is it possible the SPRITE(X,n) function is buggy in that version?


Works on 5.05.06b15. Can't remember when/if fixed
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 04:46pm 02 Oct 2020
Copy link to clipboard 
Print this post

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: Australia
Posts: 341
Posted: 09:48am 12 Oct 2020
Copy link to clipboard 
Print this post

  matherp said  
  Quote  I am still on 5.05.03. Is it possible the SPRITE(X,n) function is buggy in that version?


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)).

  Quote  
Works on 5.05.06b15. Can't remember when/if fixed


I know it was fixed some time after 5.05.04.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025