CPSceneObjectContext
Scene object context during frame update.
This type is main access point to the most of CosPlay functionality for the scene objects comprising the gameplay. On each game frame update all scene objects from the current scene receive CPSceneObject.update call and optional CPSceneObject.render call both of which receive the instance of this type. Also, the shaders attached to that scene objects, if any, receive the callback with the instance of this type.
Scene object context functionality can be grouped into:
- Keyboard input focus management
- Accessing, adding, and removing scene objects
- Access game and scene user-data storage
- Access game log
- Adding, removing, and switching scenes
- Check collisions
- Send and receive messages between scene objects
- Accessing game & rendering statistics
- Getting scene canvas to draw on
- Accessing scene camera descriptor
- Exiting game
Attributes
- See also:
- Source:
- CPSceneObjectContext.scala
- Graph
- Supertypes
Members list
Value members
Abstract methods
Makes the scene object with given ID the owner of the input keyboard focus.
Makes the scene object with given ID the owner of the input keyboard focus.
Attributes
- id
ID of the scene object.
- See also:
- Source:
- CPSceneObjectContext.scala
Adds given scene object to the scene after this update cycle. Change will be visible only on the next frame update.
Adds given scene object to the scene after this update cycle. Change will be visible only on the next frame update.
Attributes
- obj
Scene object to add.
- Source:
- CPSceneObjectContext.scala
Adds new scene. Change will be visible only on the next frame update.
Adds new scene. Change will be visible only on the next frame update.
Attributes
- delCur
If immediately switching to the new scene, whether or not to remove the current scene.
- newSc
A scene to add.
- switchTo
Whether or not to immediately switch to this scene right after this frame update cycle.
- Source:
- CPSceneObjectContext.scala
Gets the sequence of scene objects this object is colliding with. If no collisions are detected - this method returns an empty list.
Gets the sequence of scene objects this object is colliding with. If no collisions are detected - this method returns an empty list.
NOTE: for a scene object to participate in the collision it must provide its collision shape. If scene object does not provide the collision shape (the default behavior) it will be ignored when checking for collision by other scene objects, and an exception will be thrown if such object initiates the check for the collision with itself.
Attributes
- zs
Zero or more Z-indexes to check collision at. If none provided, scene objects at all Z-indexes with be checked.
- See also:
- Source:
- CPSceneObjectContext.scala
Gets the sequence of scene objects colliding with given rectangular. If no collisions are detected - this method returns an empty list.
Gets the sequence of scene objects colliding with given rectangular. If no collisions are detected - this method returns an empty list.
NOTE: for a scene object to participate in the collision it must provide its collision shape. If scene object does not provide the collision shape (the default behavior) it will be ignored when checking for collision by other scene objects, and an exception will be thrown if such object initiates the check for the collision with itself.
Attributes
- zs
Zero or more Z-indexes to check collision at. If none provided, scene objects at all Z-indexes with be checked.
- See also:
- Source:
- CPSceneObjectContext.scala
Gets the sequence of scene objects colliding with given coordinate. If no collisions are detected - this method returns an empty list.
Gets the sequence of scene objects colliding with given coordinate. If no collisions are detected - this method returns an empty list.
NOTE: for a scene object to participate in the collision it must provide its collision shape. If scene object does not provide the collision shape (the default behavior) it will be ignored when checking for collision by other scene objects, and an exception will be thrown if such object initiates the check for the collision with itself.
Attributes
- zs
Zero or more Z-indexes to check collision at. If none provided, scene objects at all Z-indexes with be checked.
- See also:
- Source:
- CPSceneObjectContext.scala
Gets number of scene objects with given tags. All tags must be present in the scene object to be returned as part of the result sequence.
Gets number of scene objects with given tags. All tags must be present in the scene object to be returned as part of the result sequence.
Attributes
- tags
One or more tags to filter by.
- Source:
- CPSceneObjectContext.scala
Deletes given scene object after this update cycle. Change will be visible only on the next frame update. Note that focus owner will be released if held by the deleted object.
Deletes given scene object after this update cycle. Change will be visible only on the next frame update. Note that focus owner will be released if held by the deleted object.
Attributes
- id
ID of the scene object to delete after this update cycle.
- Source:
- CPSceneObjectContext.scala
Deletes given scene. Note that you can't delete current scene.
Deletes given scene. Note that you can't delete current scene.
Attributes
- id
ID of the scene to delete. Cannot be the current scene.
- Source:
- CPSceneObjectContext.scala
Exits the CPEngine.startGame method.
Gets camera control descriptor for the current scene.
Gets current camera frame. Camera frame is always a sub-region of the scene. In most cases, it is a smaller value between scene dimension and terminal dimension.
Gets current camera frame. Camera frame is always a sub-region of the scene. In most cases, it is a smaller value between scene dimension and terminal dimension.
Attributes
- Source:
- CPSceneObjectContext.scala
The canvas instance on which this scene object renders its content. In most cases, you should only render in CPSceneObject.render call.
The canvas instance on which this scene object renders its content. In most cases, you should only render in CPSceneObject.render call.
Attributes
- Source:
- CPSceneObjectContext.scala
Gets ID of the scene object owning the input focus, if any. If None
- no object is
owning the input focus and all objects will get input events.
Gets ID of the scene object owning the input focus, if any. If None
- no object is
owning the input focus and all objects will get input events.
Attributes
- See also:
- Source:
- CPSceneObjectContext.scala
ID of the scene object that is being processed.
Gets current frame's keyboard event.
Gets scene object with given ID.
Gets scene object with given ID.
Attributes
- id
ID of the scene object to get.
- Source:
- CPSceneObjectContext.scala
Gets sequence of scene objects with given tags. All tags must be present in the scene object to be returned as part of the result sequence.
Gets sequence of scene objects with given tags. All tags must be present in the scene object to be returned as part of the result sequence.
Attributes
- tags
One or more tags to filter by.
- Source:
- CPSceneObjectContext.scala
Gets the current owner of input keyboard focus.
Gets rendering statistics, if available.
Gets scene object with given ID. Throws CPException exception if object with given ID not found.
Gets scene object with given ID. Throws CPException exception if object with given ID not found.
Attributes
- id
ID of the scene object to get.
- Throws:
- CPException
Thrown if object with given ID not found.
- Source:
- CPSceneObjectContext.scala
Checks whether the object this context is attached to is visible.
Checks whether the object this context is attached to is visible.
Attributes
- Source:
- CPSceneObjectContext.scala
Gets direct messages send to this scene object, if any. Returns an empty sequence if no messages pending delivery. Note that sent messages are stored until they are retrieved or the scene is changed.
Gets direct messages send to this scene object, if any. Returns an empty sequence if no messages pending delivery. Note that sent messages are stored until they are retrieved or the scene is changed.
Attributes
- See also:
- Source:
- CPSceneObjectContext.scala
Releases the input focus if it is help by the object with given ID. No-op in all other cases.
Releases the input focus if it is help by the object with given ID. No-op in all other cases.
Attributes
- id
ID of the scene object.
- See also:
- Source:
- CPSceneObjectContext.scala
Releases the input keyboard focus if it is held by the current scene object. No-op in all other cases.
Releases the input keyboard focus if it is held by the current scene object. No-op in all other cases.
Attributes
- See also:
- Source:
- CPSceneObjectContext.scala
Schedules given function to run at least delayMs
milliseconds later or upon scene switch. Given
function will only run if its timer elapses during the current scene or scene changes. Note that
given function will run at the minimum the next frame and never in the current frame
(even if delayMs
is set to 1ms, for example).
Schedules given function to run at least delayMs
milliseconds later or upon scene switch. Given
function will only run if its timer elapses during the current scene or scene changes. Note that
given function will run at the minimum the next frame and never in the current frame
(even if delayMs
is set to 1ms, for example).
Attributes
- delayMs
Minimum number of milliseconds before given function will run in the current scene. Note that the actual delay can be bigger but never smaller than this parameter unless scene changes.
- f
A function to run later in the current scene.
- Source:
- CPSceneObjectContext.scala
Schedules given function to run at the next frame update. More specifically, this function will run before any of the scene objects updates on the next frame. Given function will only run if the next frame belongs to the same scene. In other words, at scene switch all currently pending functions will be discarded.
Schedules given function to run at the next frame update. More specifically, this function will run before any of the scene objects updates on the next frame. Given function will only run if the next frame belongs to the same scene. In other words, at scene switch all currently pending functions will be discarded.
Attributes
- f
A function to run in the next frame update of the current scene.
- Source:
- CPSceneObjectContext.scala
Sends direct message(s) to the scene object with given ID. Scene object must belong to the current scene, i.e. one cannot send a message to the scene objects from another scene. To exchange data between scenes you should use game cache. Note that messages will be available to recipient scene objects starting with the next frame. Messages will be stored until they are retrieved or the scene is changed.
Sends direct message(s) to the scene object with given ID. Scene object must belong to the current scene, i.e. one cannot send a message to the scene objects from another scene. To exchange data between scenes you should use game cache. Note that messages will be available to recipient scene objects starting with the next frame. Messages will be stored until they are retrieved or the scene is changed.
Attributes
- id
Scene object ID from the current scene.
- msgs
Messages to send.
- See also:
- Source:
- CPSceneObjectContext.scala
Switches to the given scene. Note that switch will happen only after the current frame update cycle completes.
Switches to the given scene. Note that switch will happen only after the current frame update cycle completes.
Attributes
- delCur
Whether or not to remove the current scene.
- id
ID of the scene to switch to.
- Source:
- CPSceneObjectContext.scala
Concrete methods
Makes the current scene object the owner of the input keyboard focus.
Makes the current scene object the owner of the input keyboard focus.
Attributes
- See also:
- Source:
- CPSceneObjectContext.scala
Deletes current scene object after this update cycle. Change will be visible only on the next frame update. Note that focus owner will be released if held by the this object.
Deletes current scene object after this update cycle. Change will be visible only on the next frame update. Note that focus owner will be released if held by the this object.
Attributes
- Source:
- CPSceneObjectContext.scala
Deletes scene objects with given tags. All tags must be present in the scene object to be deleted. Change will be visible only on the next frame update. Note that focus owner will be released if held by the deleted object.
Deletes scene objects with given tags. All tags must be present in the scene object to be deleted. Change will be visible only on the next frame update. Note that focus owner will be released if held by the deleted object.
Attributes
- tags
One or more tags to filter by.
- Source:
- CPSceneObjectContext.scala
Tests whether or not current object is a input keyboard focus owner.
Tests whether or not current object is a input keyboard focus owner.
Attributes
- See also:
- Source:
- CPSceneObjectContext.scala
Checks if the current frame's keyboard event, if any, contains given keyboard key.
Checks if the current frame's keyboard event, if any, contains given keyboard key.
Attributes
- key
Keyboard key to check.
- See also:
CPKeyboardEvent.key
- Source:
- CPSceneObjectContext.scala
Switches to the given scene as well as settings game cache parameters before the switch. Note that switch will happen only after the current frame update cycle completes.
Switches to the given scene as well as settings game cache parameters before the switch. Note that switch will happen only after the current frame update cycle completes.
Attributes
- cacheProps
Game cache parameters to set before switching the scene.
- delCur
Whether or not to remove the current scene.
- id
ID of the scene to switch to.
- Source:
- CPSceneObjectContext.scala
Inherited methods
Gets global frame count for the game.
Gets global frame count for the game.
Attributes
- Inherited from:
- CPBaseContext
- Source:
- CPBaseContext.scala
Gets the timestamp in milliseconds for the current frame.
Gets the timestamp in milliseconds for the current frame.
This value will be the same for all objects across all callbacks for the entirety of the
current frame processing. It is used to provide the time
simultaneity
across all scene
objects at a given frame.
Attributes
- Inherited from:
- CPBaseContext
- Source:
- CPBaseContext.scala
Gets game-wide cache. Game-wide cache can be used to share data across scenes.
Gets game-wide cache. Game-wide cache can be used to share data across scenes.
A cache is a map-like type that is used for game-wide and scene-wide user-data containers. The instances of this class are created and managed by the game engine. Scene and game caches can be used to exchange and store user-defined data between frames of the same scene or between scenes of the game. Note that by default these caches are in-memory only and not persistent between game executions. One could, however, add persistence using one of the lifecycle methods available through CPLifecycle type that is extended by both CPSceneObject and CPScene types.
Attributes
- See also:
- Inherited from:
- CPBaseContext
- Source:
- CPBaseContext.scala
Gets log instance.
Gets scene-wide cache. Scene-wide cache gets cleared when scene changes.
Gets scene-wide cache. Scene-wide cache gets cleared when scene changes.
A cache is a map-like type that is used for game-wide and scene-wide user-data containers. The instances of this class are created and managed by the game engine. Scene and game caches can be used to exchange and store user-defined data between frames of the same scene or between scenes of the game. Note that by default these caches are in-memory only and not persistent between game executions. One could, however, add persistence using one of the lifecycle methods available through CPLifecycle type that is extended by both CPSceneObject and CPScene types.
Attributes
- See also:
- Inherited from:
- CPBaseContext
- Source:
- CPBaseContext.scala
Gets frame count since the beginning of the current scene.
Gets frame count since the beginning of the current scene.
Attributes
- Inherited from:
- CPBaseContext
- Source:
- CPBaseContext.scala
Gets the timestamp in milliseconds of the game start.
Gets the timestamp in milliseconds of the game start.
Attributes
- Inherited from:
- CPBaseContext
- Source:
- CPBaseContext.scala
Gets the timestamp in milliseconds of the current scene start.
Gets the timestamp in milliseconds of the current scene start.
Attributes
- Inherited from:
- CPBaseContext
- Source:
- CPBaseContext.scala