Hey so I am now attempting to create a collision detection that will cause a linear change to launch the player upwards…
The colliders show up around the entities and are anchored in them as should be,
here is my code..
import QtQuick 2.7
import QtQuick.Window 2.2
import Felgo 3.0
GameWindow {
id:gameWindow
width: Screen.width
height: Screen.height
Item {
width:Screen.width
height:Screen.height-10
focus: true
Keys.onPressed: {
if (event.key===Qt.Key_Right){
event.accepted = true;
walk.x=(walk.x) +7
}
if (event.key===Qt.Key_Left){
event.accepted = true;
walk.x=(walk.x) -7
}
}
Flickable{
width:Screen.width
height:Screen.height
contentHeight: Screen.height *4
contentWidth: Screen.width
interactive: true
boundsBehavior: Flickable.StopAtBounds
Image{
id: box
anchors.fill: parent
source: "../assets/rect.png"
sourceSize.width: Screen.width
sourceSize.height: Screen.height*4
}
Scene {
Image{
id:twitter
source: "../assets/twitter.png"
x:128
y:80
width:145
height:170
}
PhysicsWorld
{
gravity.y: 9.81
debugDrawVisible: true
}
EntityManager {
id: entityManager
entityContainer: scene// this property is needed if you want to dynamically create entities at runtime, if you don't do this, you can remove it.
}
EntityBase {
id: cannonbox
entityId: "cannonbox"
entityType: "box"
width: 125
height: 190
x:100
y:250
AnimatedSprite {
id: cannon
anchors.fill: cannonbox
width: 150
height: 212
source: "../assets/cannon.png"
frameCount: 12
frameRate: 8
frameWidth: 128
frameHeight:155
loops: 100
}
BoxCollider {
id:box1
anchors.fill: parent
collisionTestingOnlyMode: true
}
}
EntityBase {
id: player
entityId: "player"
entityType: "box"
width: 70
height: 125
AnimatedSprite {
id: walk
width: 35
height: 90
source: "../assets/WalkingManSpriteSheet.png"
frameCount: 8
frameRate: 6
frameWidth: 41
frameHeight:49
loops: 100
x: 20
y: 230
}
BoxCollider {
id:box2
anchors.fill: walk
focus: true
collisionTestingOnlyMode: true
fixture.onBeginContact: {
// for access of the collided entity and the entityType and entityId:
var body = other.getBody();
var collidedEntity = body.target;
var collidedEntityType = collidedEntity.entityType;
var collidedEntityId = collidedEntity.entityId;
}
}
}
}
}
}
}
What do i need to do the the fixture.onBeginContact to make the linear change? I’ve tried looking at examples but I’m at a loss right now. Thanks!