Hi Darren,
the camera is focusing the center of the focusedObject by default, so maybe there’s some other issue in your code. I prepared a sample that extends the camera with your requested rotation-lock:
import Felgo 3.0
import QtQuick 2.0
GameWindow {
activeScene: gameScene
EntityManager {
id: entityManager
entityContainer: gameScene.container
}
Scene {
id: gameScene
// forward the keyboard input to the TwoAxisController
Keys.forwardTo: controller
Item {
id: container
/*
THIS IS WHERE THE MAGIC HAPPENS
We transform the container with a Rotation element in order to be able to set a custom transform origin (the "transformOrigin" property of the Item only allows to use enums for certain edges or the center)
The custom origin is the center of the player thats why we add half the width.
*/
transform: Rotation { origin.x: player.x + player.width/2; origin.y: player.y + player.height/2; angle: -player.rotation;}
PhysicsWorld {
debugDrawVisible: true
}
// the controllable entity
EntityBase {
id: player
x: 100; y: 300
width: 32; height: 32
// Rotate the player around it's center and not the default 0,0 origin
transformOrigin: Item.Center
Rectangle {
anchors.fill: parent
color: "blue"
}
Rectangle {
color: "red"
width: parent.height
height: 5
anchors.top: parent.top
}
// this controller helps to move the player
TwoAxisController {
id: controller
}
BoxCollider {
anchors.fill: parent
// set the velocity, depending on which arrow keys are pressed
linearVelocity: Qt.point(controller.yAxis * 100 * Math.sin(player.rotation*Math.PI/180), -controller.yAxis * 100 * Math.cos(player.rotation*Math.PI/180))
angularVelocity: controller.xAxis * 70
}
}
// 5 green rectangles to make the player's movement visible
Rectangle {
x: 0; y: 0
width: 32; height: 32
color: "green"
}
Rectangle {
x: 668; y: 368
width: 32; height: 32
color: "green"
}
Rectangle {
x: 668; y: 0
width: 32; height: 32
color: "green"
}
Rectangle {
x: 0; y: 368
width: 32; height: 32
color: "green"
}
Rectangle {
x: 334; y: 184
width: 32; height: 32
color: "green"
}
}
CameraVPlay {
id: camera
// set the gameWindowSize and entityContainer required for the camera
gameWindowSize: Qt.point(gameScene.gameWindowAnchorItem.width, gameScene.gameWindowAnchorItem.height)
entityContainer: container
// the camera follows the player
focusedObject: player
}
}
}
Hope this helps you for now, we’ll have to check if we can add this feature to the camera.
Cheers,
Alex