This class provides the root class of an application scene.
Most applications are composed of one or more scenes, with the application root responsible for switching between them. Typically these scenes have associated scene graphs. However scene graphs are specific to a rendering pipeline. Therefore it is useful to have a base class that is pipeline agnostic.
Scenes are designed to fill the entire screen. However, to better support aspect ratio independent design, many screens are height or width locked. In each case that means that this particular dimension is fixed to a particular size. This makes it possible to layout UI elements with Figma or other tools.
While Scenes are designed to fill the entire screen, it is possible to render multiple scenes on top of each other. This can be useful for transition effects or for UI layers where you want the camera to be separate from the main game layer.
This class has no static allocators as it is an abstract class intended to be subclassed
virtual bool cugl::Scene::initWithHint |
( |
float |
width, |
|
|
float |
height |
|
) |
| |
|
inlinevirtual |
Initializes a Scene with the given size hint.
Scenes are designed to fill the entire screen. If you want a scene that is only part of the screen, that should be implemented with a specific scene graph. However, the size of that screen can vary from device to device. To make scene design easier, designs are typically locked to a dimension: width or height.
This is the purpose of the size hint. If either of the values of hint are non-zero, then the scene will lock that dimension to that particular size. If both are non-zero, it will choose its dimension according to the device orientation. Landscape will be height, while portrait will pick width. Devices with no orientation will always priortize height over width.
- Parameters
-
width | The width size hint |
height | The height size hint |
- Returns
- true if initialization was successful.
Reimplemented in cugl::scene2::Scene2, and cugl::scene2::Scene2Texture.
virtual bool cugl::Scene::initWithHint |
( |
Size |
hint | ) |
|
|
virtual |
Initializes a Scene with the given size hint.
Scenes are designed to fill the entire screen. If you want a scene that is only part of the screen, that should be implemented with a specific scene graph. However, the size of that screen can vary from device to device. To make scene design easier, designs are typically locked to a dimension: width or height.
This is the purpose of the size hint. If either of the values of hint are non-zero, then the scene will lock that dimension to that particular size. If both are non-zero, it will choose its dimension according to the device orientation. Landscape will be height, while portrait will pick width. Devices with no orientation will always priortize height over width.
- Parameters
-
- Returns
- true if initialization was successful.
Reimplemented in cugl::scene2::Scene2Texture, and cugl::scene2::Scene2.
Vec3 cugl::Scene::screenToWorldCoords |
( |
const Vec2 |
screenCoords | ) |
const |
|
inline |
Returns the world space equivalent of a point in screen coordinates.
Ideally, window space and screen space would be the same space. They are both defined by the viewport and have the same offset and dimension. However, screen coordinates have the origin in the top left while window coordinates have the origin in the bottom left.
This method is important for converting event coordinates (such as a mouse click) to world coordinates. Note that not all scenes support the third dimension.
- Parameters
-
screenCoords | The point in screen coordinates |
- Returns
- the world space equivalent of a point in screen coordinates.
Vec2 cugl::Scene::worldToScreenCoords |
( |
const Vec3 |
worldCoords | ) |
const |
|
inline |
Returns the screen space equivalent of a point in world coordinates.
Ideally, window space and screen space would be the same space. They are both defined by the viewport and have the same offset and dimension. However, screen coordinates have the origin in the top left while window coordinates have the origin in the bottom left.
This method is important for converting world coordinates to event coordinates (such as a mouse click). Note that not all scenes support the third dimension.
- Parameters
-
worldCoords | The point in wprld coordinates |
- Returns
- the screen space equivalent of a point in world coordinates.