Nirvana2D API
This API is what allows developers to access objects created in the Nirvana2D editor inside RCBasic.
Nirvana Types
Type Nirvana_Vector2D
Type Nirvana_Size2D
Type Nirvana_Sprite
-
Dim Name$
-
Dim BaseName$
-
Dim Sprite_ID
-
Dim Animation_Name_Index
-
Dim Animation_Count
Type Nirvana_TileMap
-
Dim TilesetName$
-
Dim Tileset_ID
-
Dim TileMap_ID
-
Dim Mask_Index
-
Dim Mask_Count
Type Nirvana_Background
-
Dim Image_ID
-
Dim RenderSetting
Type Nirvana_Shape
-
Dim Sprite_ID
-
Dim ShapeType
Type Nirvana_Layer
-
Dim Name$
-
Dim LayerType
-
Dim Visible
-
Dim Alpha
-
Dim Scroll_Speed As Nirvana_Vector2D
-
Dim Ref_Canvas
-
Dim Layer_TileMap As Nirvana_TileMap
-
Dim Layer_Sprite_Count
-
Dim Layer_Shape_Count
-
Dim Bkg As Nirvana_Background
Type Nirvana_Stage
-
Dim Active
-
Dim Name$
-
Dim Tile_Size As Nirvana_Size2D
-
Dim Stage_Size As Nirvana_Size2D
-
Dim Layer_Count
-
Dim Viewport_Size As Nirvana_Size2D
-
Dim Stage_Offset As Nirvana_Vector2D
Function Nirvana_CreateVector2D(x, y) As Nirvana_Vector2D
Function Nirvana_CreateSize2D(w, h) As Nirvana_Size2D
Function Nirvana_CreateSprite(spriteDefinition_name$, sprite_name$) As Nirvana_Sprite
-
Create a Nirvana Sprite
-
NOTE: spriteDefinition_name$ is the name of the base sprite created in the Sprite Editor
Function Nirvana_CreateTileMap(tset_name$, tmap_width, tmap_height) As Nirvana_TileMap
Nirvana Stages
Function Nirvana_LoadStage(stage_name$, viewport_x, viewport_y, viewport_w, viewport_h)
-
Loads a stage and sets the part of the window to render it to
Sub Nirvana_Update()
-
This update function must be used in place of Update() when using Nirvana2D
Nirvana Layers
Function Nirvana_GetLayerIndex(layer_name$)
-
Returns the internal nirvana index associated with the given layer name or -1 if layer name is not an existing layer
Function Nirvana_GetLayerCanvasID(layer_index)
-
Returns the RCBasic canvas of the given nirvana layer index or -1 if layer_index is not a valid layer
Function Nirvana_GetLayerType(layer_index)
-
Returns the layer type or -1 if layer_index is not a valid layer
-
Possible Layer Types
-
NIRVANA_LAYER_TYPE_TILEMAP
-
NIRVANA_LAYER_TYPE_SPRITE
-
NIRVANA_LAYER_TYPE_CANVAS_2D
-
NIRVANA_LAYER_TYPE_CANVAS_3D
Function Nirvana_GetLayerName$(layer_index)
-
Returns the name of the given layer or an empty string if layer is not valid
Function Nirvana_GetLayerAlpha(layer_index)
-
Returns the layer alpha value set in the layer settings in Nirvana
Function Nirvana_GetLayerScrollSpeed(layer_index) As Nirvana_Vector2D
-
Returns the HScroll and VScroll speed as a vector
Function Nirvana_GetLayerTileSetName$(layer_index)
-
Returns the name of tileset associated with the given layer or empty string if layer is not valid
Function Nirvana_GetLayerTileSetID(layer_index)
-
Returns the RCBasic tileset associated with the given Nirvana layer or -1 if layer is not valid
Function Nirvana_GetLayerTileMapID(layer_index)
-
Returns the RCBasic tile map associated with the given layer or -1 if layer is not valid
Function Nirvana_GetLayerTileMaskCount(layer_index)
-
Returns the number of tile mask on a layers tileset
Function Nirvana_GetLayerTileMaskIndex(layer_index, mask_num)
-
Returns the Nirvana tile mask index for the given mask number in a layer or -1 if not a valid layer or mask number
-
mask_num should be a number from 0 to Nirvana_GetLayerTileMaskCount(layer_index)-1
Function Nirvana_GetLayerSpriteCount(layer_index)
-
Returns the number of sprites in a layer
Function Nirvana_GetLayerSpriteIndex(layer_index, sprite_name$)
-
Returns the Nirvana sprite index of the given sprite name in the given layer or -1 if sprite is not found
Function Nirvana_GetLayerShapeCount(layer_index)
-
Returns the number of stage collision shapes in the given layer
Function Nirvana_GetLayerBackgroundImageID(layer_index)
-
Returns the RCBasic image id of the image set on the given layer or -1 if no image is set
Function Nirvana_SetLayerBackgroundImage(layer_index, image_id)
-
Sets a new image on the given layer (NOTE: Layer must be a Canvas2D layer)
Function Nirvana_GetLayerBackgroundRenderType(layer_index)
-
Returns the render type of the layer image set in Nirvana2D
-
Possible Render Types
-
NIRVANA_IMG_RENDER_SETTING_NORMAL
-
NIRVANA_IMG_RENDER_SETTING_STRETCHED
-
NIRVANA_IMG_RENDER_SETTING_TILED
Function Nirvana_SetLayerBackgroundRenderType(layer_index, render_type)
-
Sets the render type of the layer image (NOTE: Layer must be a Canvas2D layer)
-
Possible Render Types
-
NIRVANA_IMG_RENDER_SETTING_NORMAL
-
NIRVANA_IMG_RENDER_SETTING_STRETCHED
-
NIRVANA_IMG_RENDER_SETTING_TILED
TILE MASK
Function Nirvana_GetTileMaskName$(mask_index)
-
Returns the name of the given tile mask or an empty string if the mask index is not valid
Function Nirvana_GetTileMaskMatrix(mask_index)
-
Returns the RCBasic matrix id of the given mask or -1 if the mask is not valid
Function Nirvana_GetLayerMaskHit(layer_index, mask_index, x, y)
-
Returns TRUE if the tile at the given position is flagged in the given mask
-
NOTE: (x, y) is a world position and not a row and column position in the tile map
SPRITES
Function Nirvana_GetSpriteID(sprite_index)
-
Returns the RCBasic sprite id of the given Nirvana sprite index or -1 if the sprite index is not valid
Function Nirvana_GetSpriteName$(sprite_index)
-
Returns the sprite name of the given Nirvana sprite index or an empty string if sprite index is not valid
Function Nirvana_GetSpriteDefinitionName$(sprite_index)
-
Returns the sprite definition name of the given sprite index
-
NOTE: Sprite Definition name is the name of the base sprite created in the Sprite Editor and not the name of the sprite in the stage
-
NOTE: There is almost no reason to get this definition name unless you wanted to look up sprites in the stage by the base sprite
Function Nirvana_GetSpriteAnimationCount(sprite_index)
-
Returns the number of animations for the given Nirvana sprite index
Function Nirvana_GetSpriteAnimationName$(sprite_index, animation_num)
-
Returns the name of the given Nirvana Sprite Index animation number
CAMERA
Sub Nirvana_SetStageOffset(offset As Nirvana_Vector2D)
Function Nirvana_GetStageOffset() As Nirvana_Vector2D
-
Returns the camera position
VIEWPORT
Sub Nirvana_SetStageViewport(v_position As Nirvana_Vector2D, v_size As Nirvana_Size2D)
-
Returns the current viewport position and size
Function Nirvana_GetViewportPosition() As Nirvana_Vector2D
-
Returns the current viewport position
Function Nirvana_GetViewportSize() As Nirvana_Size2D
-
Returns the current viewport size