Bacon2D

Scene QML Type

The root view in the Game. More...

Import Statement: import Bacon2D 1.0

Properties

Methods

  • void rayCast(RayCast * rayCast, const QPointF & point1, const QPointF & point2)

Detailed Description

The Scene component is the root view for the Game.

The size of the Scene can be larger than the size of the Game, accessible using a Viewport. The Viewport provides xOffset and yOffset properties which can be used to control movement of the Viewport.

Example usage:

import QtQuick 2.0
import Bacon2D 1.0

Game {
    id: game
    width: 800
    height: 600

    Scene {
        id: scene
        width: 1200
        height: 800
        physics: true
        viewport: Viewport {
            yOffset: player.y - 100
        }
        Entity {
            id: player
        }
    }
}

Property Documentation

debug : bool

* *

This property allows toggling debug mode, if enabled along with physics, an overlay showing fixtures will be shown.


enterAnimation : Animation

Animation that will be triggered when the Scene become the current Scene.

While Scene is executing the enter animation, running, enabled and focus properties will be set to false and there will be no user interaction until the animation is completed. It is also important to now that properties changed during enter and exit animation will be persisted when the Scene become the current Scene.

Example usage:

import QtQuick 2.0
import Bacon2D 1.0

Game {
    id: game
    width: 800
    height: 600

    Scene {
        id: scene
        width: 300
        height: 300

        enterAnimation: NumberAnimation{ target:scene; property: "x"; from: 500; to: 0; duration: 300}
        enterAnimation: NumberAnimation{ target:scene; property: "x"; from: 0; to: 500; duration: 300}
    }
}

exitAnimation : Animation

Animation that will be triggered when the Scene exits the screen. While Scene is executing the exit animation, running, enabled and focus properties will be set to false and there will be no user interaction until the animation is completed, but the Scene continue to be visible untile the animation ends. It is also important to now that properties changed by the enter and exit animation will be persisted when the Scene become the current Scene.

Example usage:

import QtQuick 2.0
import Bacon2D 1.0

Game {
    id: game
    width: 800
    height: 600

    Scene {
        id: scene
        width: 300
        height: 300

        enterAnimation: NumberAnimation{ target:scene; property: "x"; from: 500; to: 0; duration: 300}
        enterAnimation: NumberAnimation{ target:scene; property: "x"; from: 0; to: 500; duration: 300}
    }
}

game : Game

Holds the a reference to the Game that contains the Scene.


gravity : QPointF

This property holds the global gravity vector.

The gravity property only applies if physics is enabled.


physics : bool

This property determines if the Scene contains a Box2D physics world


pixelsPerMeter : float

This property holds the number of pixels per meter.

The physics world uses meters to measure velocity, movement, etc. This property only applies with physics enabled.


running : bool

The current running state of Scene


viewport : Viewport

Holds the a reference to the Viewport for the current Scene.


world : World

Holds the a reference to the World attached to the Scene.


Method Documentation

void rayCast(RayCast * rayCast, const QPointF & point1, const QPointF & point2)

The rayCast method can be used to do line-of-sight checks, fire guns, etc.

The rayCast method is only useful with physics is enabled.