CRM64Pro GDK v0.15.0
A free cross-platform game development kit built on top of SDL 3.0
Loading...
Searching...
No Matches

Description

Scene objects for 2D tile-based game development.

The Scene Core module is a robust 2D engine designed for creating complex tile-based games. It features a unified layer system that integrates standard Tile Maps, high-performance Object layers, and standalone Image layers into a single cohesive rendering pipeline.

Classes

class  CRM64Pro::Scene
 Scene class. More...

Functions

bool CRM64Pro::Scene::info (Sint32 iMode=-1) override
 Request detailed Scene object information.
const string & CRM64Pro::Scene::getName () const override
 Get the name.
Uint32 CRM64Pro::Scene::getID () const override
 Get the ID.
Sint32 CRM64Pro::Scene::getWidth () const
 Get the total width of the level in pixels.
Sint32 CRM64Pro::Scene::getHeight () const
 Get the total height of the level in pixels.
Sint32 CRM64Pro::Scene::getLayerCount (eSceneLayerType eType=SLT_EMPTY) const
 Get the number of allocated layer slots.
Sint32 CRM64Pro::Scene::createLayer (const string &sName, eSceneLayerType eType, Sint32 idLayer=-1, Sint32 iParam1=0, Sint32 iParam2=0)
 Create a new layer.
Sint32 CRM64Pro::Scene::addLayer (SceneLayer *pLayer, Sint32 idLayer=-1)
 Add an existing layer instance.
bool CRM64Pro::Scene::closeLayer (Sint32 layer)
 Close and destroy a layer.
bool CRM64Pro::Scene::clear ()
 Free all resources of current map (layer maps and tilesets).
bool CRM64Pro::Scene::setViewport (SDL_Rect *rect)
 Set the desired viewport.
bool CRM64Pro::Scene::getViewport (SDL_Rect *out) const
 Get the current viewport.
bool CRM64Pro::Scene::setBackgroundColor (Uint32 iRGBA)
 Set background color.
Uint32 CRM64Pro::Scene::getBackgroundColor () const
 Get background color.
string CRM64Pro::Scene::getModificationDate () const
 Get the map modification date (last save date).
string CRM64Pro::Scene::getCreationDate () const
 Get the map creation date (first save date).
bool CRM64Pro::Scene::setLayerFeatures (Sint32 layer, eSceneLayerFeature eLF, bool bEnable)
 Set the layer features.
eSceneLayerFeature CRM64Pro::Scene::getLayerFeatures (Sint32 layer) const
 Get the layer features.
bool CRM64Pro::Scene::pause ()
 Pause all active layers.
bool CRM64Pro::Scene::resume ()
 Resume all active layers.
bool CRM64Pro::Scene::setLayerAlphaMod (Sint32 layer, Sint32 alpha)
 Set layer alpha modulation used for rendering this layer.
Sint32 CRM64Pro::Scene::getLayerAlphaMod (Sint32 layer) const
 Get layer alpha modulation.
bool CRM64Pro::Scene::setLayerParallaxRatio (Sint32 layer, float fPRX, float fPRY)
 Set the layer parallax ratio.
Sint32 CRM64Pro::Scene::getLayerParallaxRatio (Sint32 layer, float *fPRX, float *fPRY) const
 Get current layer parallax ratio.
bool CRM64Pro::Scene::setCameraMode (Sint32 iLayer, eSceneCameraMode eMode)
 Set camera mode for a layer.
eSceneCameraMode CRM64Pro::Scene::getCameraMode (Sint32 iLayer) const
 Get camera mode for a layer.
bool CRM64Pro::Scene::setCameraParams (Sint32 iLayer, const SceneCameraParams &params)
 Set camera parameters for a layer.
bool CRM64Pro::Scene::getCameraParams (Sint32 iLayer, SceneCameraParams *pOut) const
 Get camera parameters for a layer.
bool CRM64Pro::Scene::setCameraTarget (Sint32 iLayer, Sint32 iTargetObjectLayer, Sint32 iTargetObjectID)
 Set camera target by object layer and object ID.
bool CRM64Pro::Scene::setCameraTarget (Sint32 iLayer, SceneObject *pTarget)
 Set camera target by object pointer.
bool CRM64Pro::Scene::clearCameraTarget (Sint32 iLayer)
 Clear camera target binding for a layer.
bool CRM64Pro::Scene::setCameraPosition (Sint32 iLayer, float fX, float fY, bool bDisableNextSmooth=false)
 Set camera absolute position and force manual mode.
bool CRM64Pro::Scene::setCameraBounds (Sint32 iLayer, const SDL_FRect *pBounds)
 Set optional camera clamp bounds override for a layer.
bool CRM64Pro::Scene::getCameraBounds (Sint32 iLayer, SDL_FRect *pOut) const
 Get explicit camera clamp bounds override for a layer.
bool CRM64Pro::Scene::setCameraOffsetCallback (Sint32 iLayer, SCENE_CameraOffsetCallback fnOffset, void *pUserData)
 Set offset callback for ::SCM_OFFSET mode.
bool CRM64Pro::Scene::setCameraShake (Sint32 iLayer, float amplitudePx, Uint32 durationMs, float falloff=5.0f)
 Set a transient render-only camera shake for a layer.
bool CRM64Pro::Scene::clearCameraShake (Sint32 iLayer)
 Clear active camera shake on a layer.
Sint32 CRM64Pro::Scene::setLayerPosition (Sint32 layer, const Position &xpos=Position(PH_KEEP), const Position &ypos=Position(PH_KEEP))
Sint32 CRM64Pro::Scene::getLayerPosition (Sint32 layer, float *xpos, float *ypos) const
 Get the current layer position (in pixels).
eSceneLayerType CRM64Pro::Scene::getLayerType (Sint32 layer) const
 Get the type of a specific layer.
SceneLayerTile * CRM64Pro::Scene::accessLayerTile (Sint32 layer)
 Get a tile layer by Scene layer index.
SceneLayerObject * CRM64Pro::Scene::accessLayerObject (Sint32 layer)
 Get an object layer by Scene layer index.
SceneLayerImage * CRM64Pro::Scene::accessLayerImage (Sint32 layer)
 Get an image layer by Scene layer index.
bool CRM64Pro::Scene::setLayerOnUpdateEnd (Sint32 layer, SCENE_OnLayerCallback myfunc)
 Set an event function (onUpdateEnd) to be called when the engine finishes updating the layer.
SCENE_OnLayerCallback CRM64Pro::Scene::getLayerOnUpdateEnd (Sint32 layer)
 Get current onUpdateEnd event function if any.
bool CRM64Pro::Scene::setLayerOnRenderEnd (Sint32 layer, SCENE_OnLayerCallback myfunc)
 Set an event function (onRenderEnd) to be called when the engine finishes rendering the layer.
SCENE_OnLayerCallback CRM64Pro::Scene::getLayerOnRenderEnd (Sint32 layer)
 Get current onRenderEnd event function if any.
void CRM64Pro::Scene::setOnTriggerEvent (SceneObject::SCENE_OnTriggerEvent fn, void *pUserData=nullptr)
 Set a global trigger event callback.
bool CRM64Pro::Scene::getLayerName (Sint32 layer, string &sName) const
 Get the layer name.
bool CRM64Pro::Scene::setLayerName (Sint32 layer, const string &sName)
 Set a new layer name.
bool CRM64Pro::Scene::setDebugOverlay (eSceneDebugOverlay eFlags, bool bEnable)
 Enable or disable one or more unified debug overlay flags.
bool CRM64Pro::Scene::isDebugOverlayEnabled (eSceneDebugOverlay eFlags) const
 Check if all requested debug overlay flags are enabled.
bool CRM64Pro::Scene::setDebugOverlayColor (eSceneDebugOverlay eFlag, Uint32 iColor)
 Set debug overlay color for a specific overlay flag.
Uint32 CRM64Pro::Scene::getDebugOverlayColor (eSceneDebugOverlay eFlag) const
 Get debug overlay color for a specific overlay flag.
bool CRM64Pro::Scene::screenToWorld (Sint32 sx, Sint32 sy, float *wx, float *wy, Sint32 layer=0) const
 Convert screen coordinates to world coordinates.
bool CRM64Pro::Scene::screenToCell (Sint32 sx, Sint32 sy, Sint32 *cx, Sint32 *cy, Sint32 layer=0) const
 Convert screen coordinates to tile cell indices.
bool CRM64Pro::Scene::worldToScreen (float wx, float wy, float *sx, float *sy, Sint32 layer=0)
 Convert world coordinates to screen coordinates.
bool CRM64Pro::Scene::mouseToWorld (float *wx, float *wy, Sint32 layer=0) const
 Convert current mouse position to world coordinates.
bool CRM64Pro::Scene::mouseToCell (Sint32 *cx, Sint32 *cy, Sint32 layer=0) const
 Convert current mouse position to tile cell indices.
Sint32 CRM64Pro::Scene::update (Sint32 layer=0)
 Update status of the Scene.
Sint32 CRM64Pro::Scene::render (Sint32 layer=0, Sint32 idRes=0)
 Render the visible layers.

Function Documentation

◆ info()

bool CRM64Pro::Scene::info ( Sint32 iMode = -1)
override

Request detailed Scene object information.

Writes information to the default log.

Parameters
iMode-1 for displaying information of all layers or greater than 0 for displaying only information of the give layer id.
Returns
true on success, or false on failure.

◆ getName()

const string & CRM64Pro::Scene::getName ( ) const
override

Get the name.

Returns
The object name.

◆ getID()

Uint32 CRM64Pro::Scene::getID ( ) const
override

Get the ID.

Returns
Object ID.

◆ getWidth()

Sint32 CRM64Pro::Scene::getWidth ( ) const

Get the total width of the level in pixels.

Calculates the maximum width based on the largest layer (map or image).

Returns
Total width in pixels.

◆ getHeight()

Sint32 CRM64Pro::Scene::getHeight ( ) const

Get the total height of the level in pixels.

Calculates the maximum height based on the largest layer (map or image).

Returns
Total height in pixels.

◆ getLayerCount()

Sint32 CRM64Pro::Scene::getLayerCount ( eSceneLayerType eType = SLT_EMPTY) const

Get the number of allocated layer slots.

Returns the total number of layer slots currently allocated in the engine.

Note
This count includes empty slots (nullptr) if layers were created with non-continuous IDs. Use getLayerType() to check if a specific slot is in use.
Parameters
eTypeOptional layer type filter.
  • SLT_EMPTY (default): Returns total allocated slots (size of layer vector).
  • Other values: Returns the count of active layers matching that specific type.
Returns
The number of layers.

◆ createLayer()

Sint32 CRM64Pro::Scene::createLayer ( const string & sName,
eSceneLayerType eType,
Sint32 idLayer = -1,
Sint32 iParam1 = 0,
Sint32 iParam2 = 0 )

Create a new layer.

Factory method for creating layers. Scene owns all created layers.

Parameters
sNameLayer name for identification.
eTypeLayer type: SLT_TILE, SLT_OBJECT, or SLT_IMAGE.
idLayerOptional layer ID to assign. -1 (default) auto-assigns next available slot. If specified ID is occupied, creation fails. If ID > current count, empty layers are inserted.
iParam1Type-specific parameter:
  • SLT_TILE: map width (in cells)
  • SLT_OBJECT: spatial grid cell size (0 = default 64)
  • SLT_IMAGE: ignored
iParam2Type-specific parameter:
  • SLT_TILE: map height (in cells)
  • SLT_OBJECT: ignored
  • SLT_IMAGE: ignored
Returns
Layer index (1-based) on success, or negative error code on failure.

◆ addLayer()

Sint32 CRM64Pro::Scene::addLayer ( SceneLayer * pLayer,
Sint32 idLayer = -1 )

Add an existing layer instance.

Attach a pre-created layer (standard or user-derived) to the engine. The engine takes ownership of the pointer and will delete it upon destruction or closeLayer().

Parameters
pLayerPointer to the layer object (must be allocated with new).
idLayerOptional layer ID. -1 (default) auto-assigns next available slot.
Returns
Layer index (1-based) on success, or negative error code on failure.
Warning
Do not manually delete the layer after passing it to this method.

◆ closeLayer()

bool CRM64Pro::Scene::closeLayer ( Sint32 layer)

Close and destroy a layer.

Releases the tile layer and resets all layer settings, leaving the slot empty and ready for reuse. The engine takes ownership of the layer pointer when added and will delete it here.

Parameters
layerSelected layer to close (from 1 to number of allocated layers).
Returns
true on success or false on failure.

◆ clear()

bool CRM64Pro::Scene::clear ( )

Free all resources of current map (layer maps and tilesets).

Resets the current map. All layers are reset but layer slots are kept. Preserves viewport, map name and number of allocated layers.

Returns
true on success or false on failure.

◆ setViewport()

bool CRM64Pro::Scene::setViewport ( SDL_Rect * rect)

Set the desired viewport.

You can change the viewport at any time even while you are rendering your application. The width and height of the viewport can not be greater than values of the smallest layer (excluding the ones with looping features), otherwise, it will be automatically adjusted.

Parameters
rectPointer to SDL_Rect with the desired viewport. If the rect width or height is 0, it will use the whole target (a valid screen or image handle).
Returns
true on success or false on failure.

◆ getViewport()

bool CRM64Pro::Scene::getViewport ( SDL_Rect * out) const

Get the current viewport.

Parameters
outPointer to SDL_Rect that receives the current effective viewport.
Returns
true on success or false on failure (e.g. out is nullptr).

◆ setBackgroundColor()

bool CRM64Pro::Scene::setBackgroundColor ( Uint32 iRGBA)

Set background color.

Parameters
iRGBAbackground color to set in the format RGBA. When A is 0 (totally transparent), the background color is disabled.
Returns
true on success or false on failure.

◆ getBackgroundColor()

Uint32 CRM64Pro::Scene::getBackgroundColor ( ) const

Get background color.

Returns
the background color in format RGBA. When A is 0 (totally transparent, the background color is disabled)

◆ getModificationDate()

string CRM64Pro::Scene::getModificationDate ( ) const

Get the map modification date (last save date).

Returns
a string containing the date.

◆ getCreationDate()

string CRM64Pro::Scene::getCreationDate ( ) const

Get the map creation date (first save date).

Returns
a string containing the date.

◆ setLayerFeatures()

bool CRM64Pro::Scene::setLayerFeatures ( Sint32 layer,
eSceneLayerFeature eLF,
bool bEnable )

Set the layer features.

Parameters
layerNumber of layer (from 1 to number of allocated layers).
eLFFeature or features to be enabled or disabled (can be combined using bitwise OR). Check ::eSceneLayerFeature enum for further information.
bEnabletrue for enabling the given features or false for disabling them.
Returns
true on success or false on failure.
Note
Enabling ::SLF_RENDER implicitly enables ::SLF_UPDATE for that layer.
Disabling ::SLF_RENDER does not disable ::SLF_UPDATE.

◆ getLayerFeatures()

eSceneLayerFeature CRM64Pro::Scene::getLayerFeatures ( Sint32 layer) const

Get the layer features.

Parameters
layerNumber of layer (from 1 to number of allocated layers).
Returns
A ::eSceneLayerFeature enum containing all currently enabled features.

◆ pause()

bool CRM64Pro::Scene::pause ( )

Pause all active layers.

Enables ::SLF_PAUSE on all non-disabled layers. After calling this method, specific layers can be re-enabled by disabling ::SLF_PAUSE on those layers (e.g., keep GUI layer active during modal dialogs).

Returns
true on success or false on failure.

◆ resume()

bool CRM64Pro::Scene::resume ( )

Resume all active layers.

Disables ::SLF_PAUSE on all non-disabled layers.

Returns
true on success or false on failure.

◆ setLayerAlphaMod()

bool CRM64Pro::Scene::setLayerAlphaMod ( Sint32 layer,
Sint32 alpha )

Set layer alpha modulation used for rendering this layer.

Parameters
layerSelected layer to set the alpha value (from 1 to number of allocated layers).
alphaIt ranges from 255 (opaque) to 0 (fully transparent).
Returns
true on success or false on failure.

◆ getLayerAlphaMod()

Sint32 CRM64Pro::Scene::getLayerAlphaMod ( Sint32 layer) const

Get layer alpha modulation.

Parameters
layerSelected layer to get the alpha value (from 1 to number of allocated layers)
Returns
It ranges from 255 (opaque) to 0 (fully transparent) or a negative error code on failure.

◆ setLayerParallaxRatio()

bool CRM64Pro::Scene::setLayerParallaxRatio ( Sint32 layer,
float fPRX,
float fPRY )

Set the layer parallax ratio.

Changes the real speed of any layer relative to the camera movement.

Parameters
layerSelected layer to set the parallax ratio (from 1 to number of allocated layers).
fPRXParallax ratio on X axis. 1.0 moves at standard speed. < 1.0 moves slower (background). > 1.0 moves faster (foreground). 0.0 makes the layer independent (HUD/static).
fPRYParallax ratio on Y axis. 1.0 moves at standard speed. < 1.0 moves slower (background). > 1.0 moves faster (foreground). 0.0 makes the layer independent (HUD/static).
Returns
true on success or false on failure.

◆ getLayerParallaxRatio()

Sint32 CRM64Pro::Scene::getLayerParallaxRatio ( Sint32 layer,
float * fPRX,
float * fPRY ) const

Get current layer parallax ratio.

Parameters
layerSelected layer to get the parallax ratio (from 1 to number of allocated layers).
fPRXa float pointer filled in with parallax ratio on X axis. If nullptr is passed, the method ignores the retrieving of this value.
fPRYa float pointer filled in with parallax ratio on Y axis. If nullptr is passed, the method ignores the retrieving of this value.
Returns
0 on success, or a negative error code on failure.

◆ setCameraMode()

bool CRM64Pro::Scene::setCameraMode ( Sint32 iLayer,
eSceneCameraMode eMode )

Set camera mode for a layer.

Camera mode is processed during update() for the selected layer. When switching from ::SCM_MANUAL to a target-based automatic mode, ensure a target is bound through setCameraTarget().

Note
::SCM_AUTOSCROLL does not require a camera target.
Parameters
iLayerLayer index (1..getLayerCount()).
eModeCamera mode to assign.
Returns
true on success or false on failure.

◆ getCameraMode()

eSceneCameraMode CRM64Pro::Scene::getCameraMode ( Sint32 iLayer) const

Get camera mode for a layer.

Parameters
iLayerLayer index (1..getLayerCount()).
Returns
Current camera mode, or ::SCM_MANUAL if layer is invalid.

◆ setCameraParams()

bool CRM64Pro::Scene::setCameraParams ( Sint32 iLayer,
const SceneCameraParams & params )

Set camera parameters for a layer.

Parameters are sanitized (anchors clamped to [0..1], deadzone size >= 0, damping >= 0). Applies to all non-manual camera modes.

Parameters
iLayerLayer index (1..getLayerCount()).
paramsCamera parameters.
Returns
true on success or false on failure.

◆ getCameraParams()

bool CRM64Pro::Scene::getCameraParams ( Sint32 iLayer,
SceneCameraParams * pOut ) const

Get camera parameters for a layer.

Parameters
iLayerLayer index (1..getLayerCount()).
pOutPointer to destination parameters structure.
Returns
true on success or false on failure.

◆ setCameraTarget() [1/2]

bool CRM64Pro::Scene::setCameraTarget ( Sint32 iLayer,
Sint32 iTargetObjectLayer,
Sint32 iTargetObjectID )

Set camera target by object layer and object ID.

This is the recommended binding mode because IDs remain valid across update/render frames. The target object must exist at the time of this call.

Parameters
iLayerCamera-controlled layer index (1..getLayerCount()).
iTargetObjectLayerObject layer index containing the target.
iTargetObjectIDObject ID inside the target object layer.
Returns
true on success or false on failure.

◆ setCameraTarget() [2/2]

bool CRM64Pro::Scene::setCameraTarget ( Sint32 iLayer,
SceneObject * pTarget )

Set camera target by object pointer.

Convenience overload. The engine resolves the pointer to (object layer, object id) at call time. If the object cannot be resolved, the method fails and target remains unchanged.

Note
This method stores the resolved layer/id pair (not the raw pointer) for stable runtime behavior.
Parameters
iLayerCamera-controlled layer index (1..getLayerCount()).
pTargetTarget object pointer.
Returns
true on success or false on failure.

◆ clearCameraTarget()

bool CRM64Pro::Scene::clearCameraTarget ( Sint32 iLayer)

Clear camera target binding for a layer.

Parameters
iLayerLayer index (1..getLayerCount()).
Returns
true on success or false on failure.

◆ setCameraPosition()

bool CRM64Pro::Scene::setCameraPosition ( Sint32 iLayer,
float fX,
float fY,
bool bDisableNextSmooth = false )

Set camera absolute position and force manual mode.

This method always switches the selected layer camera mode to ::SCM_MANUAL. It is intended for explicit camera control, teleports, cutscene jumps, and modal transitions.

Parameters
iLayerLayer index (1..getLayerCount()).
fXAbsolute camera X position in world pixels.
fYAbsolute camera Y position in world pixels.
bDisableNextSmoothIf true, disables one-frame interpolation to avoid visual trail after teleports/cut transitions.
Returns
true on success or false on failure.

◆ setCameraBounds()

bool CRM64Pro::Scene::setCameraBounds ( Sint32 iLayer,
const SDL_FRect * pBounds )

Set optional camera clamp bounds override for a layer.

If pBounds is nullptr, explicit bounds override is removed and automatic layer/world bounds are used. This override is only applied when SceneCameraParams::bClampToBounds is true.

Parameters
iLayerLayer index (1..getLayerCount()).
pBoundsOptional pointer to world-space bounds rectangle.
Returns
true on success or false on failure.

◆ getCameraBounds()

bool CRM64Pro::Scene::getCameraBounds ( Sint32 iLayer,
SDL_FRect * pOut ) const

Get explicit camera clamp bounds override for a layer.

Returns only explicitly assigned bounds. If no override is defined, method returns false.

Parameters
iLayerLayer index (1..getLayerCount()).
pOutPointer to destination rect.
Returns
true if explicit bounds exist and were copied, false otherwise.

◆ setCameraOffsetCallback()

bool CRM64Pro::Scene::setCameraOffsetCallback ( Sint32 iLayer,
SCENE_CameraOffsetCallback fnOffset,
void * pUserData )

Set offset callback for ::SCM_OFFSET mode.

The callback is evaluated each update tick in ::SCM_OFFSET mode. On callback failure (return false), offset {0,0} is used for that tick.

Parameters
iLayerLayer index (1..getLayerCount()).
fnOffsetCallback function pointer (nullptr disables callback).
pUserDataUser data passed back to callback.
Returns
true on success or false on failure.

◆ setCameraShake()

bool CRM64Pro::Scene::setCameraShake ( Sint32 iLayer,
float amplitudePx,
Uint32 durationMs,
float falloff = 5.0f )

Set a transient render-only camera shake for a layer.

Shake is applied additively during render interpolation and does not alter logic/world positions.

Parameters
iLayerLayer index (1..getLayerCount()).
amplitudePxMaximum shake amplitude in pixels.
durationMsShake duration in milliseconds.
falloffExponential decay factor (>= 0). Larger values decay faster.
Returns
true on success or false on failure.

◆ clearCameraShake()

bool CRM64Pro::Scene::clearCameraShake ( Sint32 iLayer)

Clear active camera shake on a layer.

Parameters
iLayerLayer index (1..getLayerCount()).
Returns
true on success or false on failure.

◆ setLayerPosition()

Sint32 CRM64Pro::Scene::setLayerPosition ( Sint32 layer,
const Position & xpos = Position(PH_KEEP),
const Position & ypos = Position(PH_KEEP) )

Changes position for linked layers according to parallax ratios. Layers with parallax ratio 0.0 are independent. If this call effectively changes the layer position, the selected layer camera mode is switched to ::SCM_MANUAL. Requires valid base tile layer or image set.

Parameters
layerlayer index (1 to getLayerCount()).
xposPosition struct with x position. Can be absolute (float) or use ::PH_LEFT/::PH_RIGHT/::PH_CENTER/::PH_KEEP helpers.
yposPosition struct with y position. Can be absolute (float) or use ::PH_TOP/::PH_BOTTOM/::PH_CENTER/::PH_KEEP helpers.
Returns
1 if the layer has moved, 0 if not or a negative error code on failure.
Note
No-op calls (e.g. ::PH_KEEP/::PH_KEEP, unchanged/clamped result) do not change camera mode.
Supports implicit conversion from float: setLayerPosition(1, 100.0f, 200.0f) or explicit helpers: setLayerPosition(1, Position(PH_CENTER), Position(PH_KEEP))

◆ getLayerPosition()

Sint32 CRM64Pro::Scene::getLayerPosition ( Sint32 layer,
float * xpos,
float * ypos ) const

Get the current layer position (in pixels).

Parameters
layerSelected layer to get its current position (from 1 to number of allocated layers).
xposPointer to float var to store the position on X axis. nullptr if you dont want to retrieve it.
yposPointer to float var to store the position on Y axis. nullptr if you dont want to retrieve it.
Returns
0 on success, or a negative error code on failure.

◆ getLayerType()

eSceneLayerType CRM64Pro::Scene::getLayerType ( Sint32 layer) const

Get the type of a specific layer.

Useful for iterating through layers to check their status without casting.

Parameters
layerLayer index (from 1 to getLayerCount()).
Returns
The layer type (SLT_TILE, SLT_OBJECT, SLT_IMAGE) or SLT_EMPTY if the layer is free/null or out of bounds.

◆ accessLayerTile()

SceneLayerTile * CRM64Pro::Scene::accessLayerTile ( Sint32 layer)

Get a tile layer by Scene layer index.

Parameters
layerScene layer index (1-based, as used by other layer methods).
Returns
Pointer to tile layer, or nulltpr if layer has no tile or is out of range.

◆ accessLayerObject()

SceneLayerObject * CRM64Pro::Scene::accessLayerObject ( Sint32 layer)

Get an object layer by Scene layer index.

Convenience method to get the object layer associated with a Scene layer.

Parameters
layerScene layer index (1-based, as used by other layer methods).
Returns
Pointer to object layer, or nullptr if layer has no objects or is out of range.

◆ accessLayerImage()

SceneLayerImage * CRM64Pro::Scene::accessLayerImage ( Sint32 layer)

Get an image layer by Scene layer index.

Parameters
layerScene layer index (1-based, as used by other layer methods).
Returns
Pointer to image layer, or nullptr if layer has no image or is out of range.

◆ setLayerOnUpdateEnd()

bool CRM64Pro::Scene::setLayerOnUpdateEnd ( Sint32 layer,
SCENE_OnLayerCallback myfunc )

Set an event function (onUpdateEnd) to be called when the engine finishes updating the layer.

Use nullptr to remove a previous onUpdateEnd event function.

Parameters
layerNumber of layer to set the event function (from 1 to number of allocated layers).
myfuncpointer to your custom event function.
Returns
true on success or false on failure.

◆ getLayerOnUpdateEnd()

SCENE_OnLayerCallback CRM64Pro::Scene::getLayerOnUpdateEnd ( Sint32 layer)

Get current onUpdateEnd event function if any.

Parameters
layerSelected layer to get current onUpdateEnd event function (from 1 to number of allocated layers).
Returns
a pointer to current event function or nullptr if there is not any assigned.

◆ setLayerOnRenderEnd()

bool CRM64Pro::Scene::setLayerOnRenderEnd ( Sint32 layer,
SCENE_OnLayerCallback myfunc )

Set an event function (onRenderEnd) to be called when the engine finishes rendering the layer.

Use nullptr to remove a previous onRenderEnd event function.

Parameters
layerNumber of layer to set the event function (from 1 to number of allocated layers).
myfuncpointer to your custom event function.
Returns
true on success or false on failure.

◆ getLayerOnRenderEnd()

SCENE_OnLayerCallback CRM64Pro::Scene::getLayerOnRenderEnd ( Sint32 layer)

Get current onRenderEnd event function if any.

Parameters
layerSelected layer to get current onRenderEnd event function (from 1 to number of allocated layers).
Returns
a pointer to current event function or nullptr if there is not any assigned.

◆ setOnTriggerEvent()

void CRM64Pro::Scene::setOnTriggerEvent ( SceneObject::SCENE_OnTriggerEvent fn,
void * pUserData = nullptr )

Set a global trigger event callback.

Global callback for every trigger event generated by any object layer in this Scene. Called after object and layer callbacks (dispatch order: object -> layer -> global).

Parameters
fnCallback function (nullptr to clear).
pUserDataUser data passed to callback.

◆ getLayerName()

bool CRM64Pro::Scene::getLayerName ( Sint32 layer,
string & sName ) const

Get the layer name.

Parameters
layerSelected layer to get its name (from 1 to number of allocated layers).
sNamea string containing the layer name.
Returns
true on success or false on failure.

◆ setLayerName()

bool CRM64Pro::Scene::setLayerName ( Sint32 layer,
const string & sName )

Set a new layer name.

Parameters
layerSelected layer to set its name (from 1 to number of allocated layers).
sNameThe name to give to the layer e.g. 'layer0'.
Returns
true on success or false on failure.

◆ setDebugOverlay()

bool CRM64Pro::Scene::setDebugOverlay ( eSceneDebugOverlay eFlags,
bool bEnable )

Enable or disable one or more unified debug overlay flags.

Parameters
eFlagsOverlay flag or combination of flags.
bEnabletrue to enable, false to disable.
Returns
true on success.

◆ isDebugOverlayEnabled()

bool CRM64Pro::Scene::isDebugOverlayEnabled ( eSceneDebugOverlay eFlags) const

Check if all requested debug overlay flags are enabled.

Parameters
eFlagsOverlay flag or combination of flags.
Returns
true when all requested flags are enabled, otherwise false.

◆ setDebugOverlayColor()

bool CRM64Pro::Scene::setDebugOverlayColor ( eSceneDebugOverlay eFlag,
Uint32 iColor )

Set debug overlay color for a specific overlay flag.

Parameters
eFlagSingle overlay flag (SDO_OBJECT_AABB, SDO_TILE_CELLGRID, SDO_TRIGGER_ZONES, SDO_CAMERA_DEADZONE).
iColorRGBA color (0xRRGGBBAA).
Returns
true on success or false on invalid flag.

◆ getDebugOverlayColor()

Uint32 CRM64Pro::Scene::getDebugOverlayColor ( eSceneDebugOverlay eFlag) const

Get debug overlay color for a specific overlay flag.

Parameters
eFlagSingle overlay flag.
Returns
RGBA color (0xRRGGBBAA), or 0 on invalid flag.

◆ screenToWorld()

bool CRM64Pro::Scene::screenToWorld ( Sint32 sx,
Sint32 sy,
float * wx,
float * wy,
Sint32 layer = 0 ) const

Convert screen coordinates to world coordinates.

Parameters
sxScreen X coordinate.
syScreen Y coordinate.
wxOptional output world X.
wyOptional output world Y.
layerLayer index (1..getLayerCount()). Use 0 to auto-select the camera-authority layer first (fallback: first render-enabled layer).
Returns
true on success or false on failure (invalid layer, non-render layer, or outside viewport).

◆ screenToCell()

bool CRM64Pro::Scene::screenToCell ( Sint32 sx,
Sint32 sy,
Sint32 * cx,
Sint32 * cy,
Sint32 layer = 0 ) const

Convert screen coordinates to tile cell indices.

Parameters
sxScreen X coordinate.
syScreen Y coordinate.
cxOptional output cell X.
cyOptional output cell Y.
layerLayer index (1..getLayerCount()). Use 0 to auto-select the camera-authority layer first (fallback: first render-enabled layer).
Returns
true on success or false on failure.
Note
Works only for tile layers.

◆ worldToScreen()

bool CRM64Pro::Scene::worldToScreen ( float wx,
float wy,
float * sx,
float * sy,
Sint32 layer = 0 )

Convert world coordinates to screen coordinates.

Parameters
wxWorld X coordinate.
wyWorld Y coordinate.
sxOptional output screen X.
syOptional output screen Y.
layerLayer index (1..getLayerCount()). Use 0 to auto-select the camera-authority layer first (fallback: first render-enabled layer).
Returns
true on success or false on failure.

◆ mouseToWorld()

bool CRM64Pro::Scene::mouseToWorld ( float * wx,
float * wy,
Sint32 layer = 0 ) const

Convert current mouse position to world coordinates.

Parameters
wxOptional output world X.
wyOptional output world Y.
layerLayer index (1..getLayerCount()). Use 0 to auto-select the camera-authority layer first (fallback: first render-enabled layer).
Returns
true on success or false on failure.

◆ mouseToCell()

bool CRM64Pro::Scene::mouseToCell ( Sint32 * cx,
Sint32 * cy,
Sint32 layer = 0 ) const

Convert current mouse position to tile cell indices.

Parameters
cxOptional output cell X.
cyOptional output cell Y.
layerLayer index (1..getLayerCount()). Use 0 to auto-select the camera-authority layer first (fallback: first render-enabled layer).
Returns
true on success or false on failure.

◆ update()

Sint32 CRM64Pro::Scene::update ( Sint32 layer = 0)

Update status of the Scene.

Only layers with ::SLF_UPDATE feature are processed. Calculates autoscroll and pre-calculations for rendering. Call as part of logic code. Optionally update individual layers. Calls onUpdateEnd event function at end of each layer update if it exists.

Parameters
layerDefault 0 updates all layers from 1 (background) to foreground. Any other value updates only that layer.
Returns
0 on success. If one or more layer updates fail, returns the first negative layer error code.

◆ render()

Sint32 CRM64Pro::Scene::render ( Sint32 layer = 0,
Sint32 idRes = 0 )

Render the visible layers.

Only layers with ::SLF_RENDER feature are processed. Uses positions from update() to render cells. Call as part of graphic update code. Select rendering order by calling with specific layers. Calls onRenderEnd at end of each layer. With ::SLF_SMOOTHSCROLL, interpolates values for smooth scrolling.

Parameters
layerDefault 0 processes all layers. Values 1 (background) to foreground process only that layer.
idResa valid screen. Default tries the default screen. Does not support rendering to an image.
Returns
0 on success. If one or more layer renders fail, returns the first negative layer error code.