Keep receiving type errors
-
Hi all, new to using Qt creator so bare with me please....
So I am trying to make a unlimited running platformer, like flappy bird. I am actually using a V-play template to make this game.
I am trying to add bombs into the space that continue to randomly run onto the screen and you must avoid them with your plane.
I keep getting a type error message when i attempt to put the bomb into the scene, here is the code
(Level.qml)import VPlay 2.0 import QtQuick 2.0 import "../entities" import "../common" Item { id: level Background { anchors.horizontalCenter: parent.horizontalCenter y: scene.gameWindowAnchorItem.y+scene.gameWindowAnchorItem.height-height } BorderElement { x: scene.gameWindowAnchorItem.x y: scene.gameWindowAnchorItem.y-20 width: scene.gameWindowAnchorItem.width height: 20 } BorderElement { y: ground.y x: scene.gameWindowAnchorItem.x width: scene.gameWindowAnchorItem.width height: 20 } Bombs { id: bombs1 delay: 0 } Bombs { id: bombs2 delay: 1.5 } Ground { id: ground anchors.horizontalCenter: parent.horizontalCenter y: scene.gameWindowAnchorItem.y+scene.gameWindowAnchorItem.height-height } function reset() { bombs1.reset() bombs2.reset() ground.reset() } function stop() { bombs1.stop() bombs2.stop() ground.stop() } function start() { bombs1.start() bombs2.start() } }
(bomb.qml)
import VPlay 2.0 import QtQuick 2.0 EntityBase { id: bombElement width: 40 height: 40 property int variationDistance: 70 property double delay: 0 MultiResolutionImage { id: bomb source: "../../assets/img/bomb.png" } BoxCollider { id: collider width: bomb.width height: bomb.height anchors.centerIn: bomb bodyType: Body.Static collisionTestingOnlyMode: true fixture.onBeginContact: { player.gameOver() } } MovementAnimation { id: animation target: parent property: "x" velocity: -150 running: true minPropertyValue: scene.gameWindowAnchorItem.x-bombElement.width*1.5 onLimitReached: { reset() } } function generateRandomValueBetween(minimum, maximum) { return Math.random()*(maximum-minimum) + minimum } function reset() { bombElement.x = scene.gameWindowAnchorItem.width+bombElement.width/2 bombElement.y = generateRandomValueBetween(-variationDistance, variationDistance)-scene.height/3 } function start() { delayTimer.restart() } function stop() { animation.stop() delayTimer.stop() } Timer { id: delayTimer interval: delay*1000 repeat: false onTriggered: { animation.start() } } Component.onCompleted: { reset() } }
These are the error messages.
file:///C:/Users/todd/OneDrive/Company/build-GoPlane-Desktop_Qt_5_7_0_MinGW_32bit-Debug/qml/MainItem.qml:46:5: Type GameScene unavailable file:///C:/Users/todd/OneDrive/Company/build-GoPlane-Desktop_Qt_5_7_0_MinGW_32bit-Debug/qml/scenes/GameScene.qml:37:5: Type Level unavailable file:///C:/Users/todd/OneDrive/Company/build-GoPlane-Desktop_Qt_5_7_0_MinGW_32bit-Debug/qml/game/Level.qml:28:5: Bombs is not a type C:\Users\todd\OneDrive\Company\build-GoPlane-Desktop_Qt_5_7_0_MinGW_32bit-Debug\debug\GoPlane.exe exited with code 0
-
@ToddPocock Looks like you are missing some of the QML types. Either their plugin is not properly installed or may be you need some more
import
's.
Refer to their documentation. -
@ToddPocock
Looks like a typo to me?You're referring "Bombs" (with an s at the end), but your QML is called "bomb.qml".
Strip the "s" and I think you'll be fine...