Box2D Examples
import QtQuick 2.0
import Felgo 4.0
EntityBase {
width: 50
height: 50
transformOrigin: Item.TopLeft
BoxCollider {
id: collider
sleepingAllowed: false
bullet: true
fixedRotation: true
density: 0.001
friction: 0.3
restitution: 0.2
groupIndex: 1
}
Rectangle {
id: rectangle
anchors.fill: parent
color: "red"
}
function moveForward() {
collider.body.linearVelocity.x = 300;
}
function moveBackward() {
collider.body.linearVelocity.x = -300;
}
function stopMoving() {
collider.body.linearVelocity.x = 0;
}
function jump() {
if (collider.body.linearVelocity.y <= 0 &&
collider.body.linearVelocity.y > -50) {
var impulse = Qt.point(0, -600);
collider.body.applyLinearImpulse(impulse, collider.body.getWorldCenter());
}