base class — PyObjectPlus
An active scene that gives access to objects, cameras, lights and scene attributes.
The activity culling stuff is supposed to disable logic bricks when their owner gets too far from the active camera. It was taken from some code lurking at the back of KX_Scene - who knows what it does!
from bge import logic
# get the scene
scene = logic.getCurrentScene()
# print all the objects in the scene
for object in scene.objects:
print(object.name)
# get an object named 'Cube'
object = scene.objects["Cube"]
# get the first object in the scene.
object = scene.objects[0]
# Get the depth of an object in the camera view.
from bge import logic
object = logic.getCurrentController().owner
cam = logic.getCurrentScene().active_camera
# Depth is negative and decreasing further from the camera
depth = object.position[0]*cam.world_to_camera[2][0] + object.position[1]*cam.world_to_camera[2][1] + object.position[2]*cam.world_to_camera[2][2] + cam.world_to_camera[2][3]
@bug: All attributes are read only at the moment.
The scene’s name, (read-only).
Type: | string |
---|
A list of objects in the scene, (read-only).
Type: | CListValue of KX_GameObject |
---|
A list of objects on background layers (used for the addObject actuator), (read-only).
Type: | CListValue of KX_GameObject |
---|
A list of lights in the scene, (read-only).
Type: | CListValue of KX_LightObject |
---|
A list of cameras in the scene, (read-only).
Type: | CListValue of KX_Camera |
---|
The current active camera.
Type: | KX_Camera |
---|
Note
This can be set directly from python to avoid using the KX_SceneActuator.
True if the scene is suspended, (read-only).
Type: | boolean |
---|
True if the scene is activity culling.
Type: | boolean |
---|
The distance outside which to do activity culling. Measured in manhattan distance.
Type: | float |
---|
True when Dynamic Bounding box Volume Tree is set (read-only).
Type: | boolean |
---|
A list of callables to be run before the render step.
Type: | list |
---|
A list of callables to be run after the render step.
Type: | list |
---|
The scene gravity using the world x, y and z axis.
Type: | list [fx, fy, fz] |
---|
Adds an object to the scene like the Add Object Actuator would.
Parameters: |
|
---|---|
Returns: | The newly added object. |
Return type: |
Removes the scene from the game.
Restarts the scene.
Replaces this scene with another one.
Parameters: | scene (string) – The name of the scene to replace this scene with. |
---|
Suspends this scene.
Resume this scene.
Return the value matching key, or the default value if its not found. :return: The key value or a default.
Draw debug visualization of obstacle simulation.