mvbg

VM_HIDE_SPRITES

VM_HIDE_SPRITES is a GBVM instruction used to hide all sprites currently displayed on the Game Boy screen. It is a macro that internally calls VM_SET_SPRITE_VISIBLE with the .SPRITES_HIDE option.

Purpose: Sprites are graphical objects that move independently of the background (e.g., characters, enemies, projectiles). There are many scenarios where you might want to temporarily or permanently hide all sprites. VM_HIDE_SPRITES is essential for:

When VM_HIDE_SPRITES is executed, the Game Boy’s hardware is instructed to stop rendering all sprites. They remain in memory but are no longer drawn to the screen.

Syntax:

VM_HIDE_SPRITES

VM_HIDE_SPRITES takes no arguments. It performs a global operation on all sprites.

Usage Example: Hiding Sprites During a Scene Transition

Imagine your game is transitioning from a gameplay area to a dialogue screen or a menu. You want to hide all characters and objects to ensure a clean visual transition.

; In your script, before initiating a scene change or displaying a full-screen UI:

; Hide all sprites on the screen
VM_HIDE_SPRITES

; Now, perform the scene transition or display the UI
VM_FADE_OUT 1 ; Fade screen to black
VM_CALL LOAD_NEW_SCENE
VM_CALL DISPLAY_MENU_SCREEN

; After the new scene or menu is ready, you might show sprites again
; VM_SHOW_SPRITES ; (If sprites are needed in the new context)

; ... continue script ...

LOAD_NEW_SCENE:
  ; ... logic to load new map, actors, etc. ...
  VM_RET

DISPLAY_MENU_SCREEN:
  ; ... logic to draw menu elements ...
  VM_RET

In this example, VM_HIDE_SPRITES is called before the screen fades out and a new scene or menu is loaded. This ensures that no lingering sprites are visible during the transition, providing a cleaner and more professional appearance. Once the new scene is ready, you would typically use VM_SHOW_SPRITES to make the relevant sprites visible again.

Analogy to other programming languages/game engines: This is analogous to globally disabling sprite rendering or setting a global visibility flag for all game objects that are sprites:

It provides a quick and efficient way to toggle the visibility of all sprites on the screen, useful for global visual changes or transitions.