Forums

OverviewV-Play 2 Support (Qt 5) › Type Error

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #15073

    Todd

    Hi all, new to using Qt creator/V-play 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

    #15074

    Alex
    V-Play Team

    Hi,

    your bomb qml file is named Bomb.qml (or is it bomb.qml with lowercase, doesn’t really matter), WITHOUT an s. The name of the qml file equals the classname of that component when used. so in your code it must be

    Bomb {
      // ...
    }

    and not

    Bombs {
      // ...
    }

    That’s why it says Bombs is not a type, because the type you defined is Bomb instead.

    Cheers,
    Alex

    #15082

    Todd

    Hey Alex, thanks for the quick response.

    So I went in an updated accordingly, and I still get the same error message.

    it is bomb.qml with a lowercase by the way.

    #15085

    Günther
    V-Play Team

    Hi Todd!

    It’s best practice that types in QML start with an uppercase-letter, so I’d recommend using Bomb.qml as the name and use Bomb as type name in your QML code. The type name always matches the filename. One thing that might also be relevant, is that you import the folder where the QML file is placed so you can access the types.

    Can you try again uppercase letter?

    Best,
    Günther

    #15088

    Todd

    Hey Gunther,

    I went in and updated the QML file with an uppercase B, its now Bomb.qml.

    Im getting these errors

     

    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: Type Bomb unavailable

    file:///C:/Users/todd/OneDrive/Company/build-GoPlane-Desktop_Qt_5_7_0_MinGW_32bit-Debug/qml/entities/Bomb.qml: File name case mismatch

    C:\Users\todd\OneDrive\Company\build-GoPlane-Desktop_Qt_5_7_0_MinGW_32bit-Debug\debug\GoPlane.exe exited with code 0

    #15089

    Günther
    V-Play Team

    Hi Todd,
    it should be okay if both the file and the typename you use starts with an uppercase.
    Please try to solve the error by making sure you get a fresh and clean build:
    – Delete the build directory
    – Open your project in Qt Creator
    – Right-click the project in the Project Explorer and select “Clean”
    – Right-click again and select “Run qmake”
    – Build the project

    Does it work now?

    #15090

    Todd

    This might sound like a dumb question but when you say delete the build directory do you mean go into the actual file explorer and delete the project or is that something you do directly in qt creator?

    #15093

    Günther
    V-Play Team

    The build directory is created additionally to the project directory, usually as a neighbour directory of the project.
    In the Qt Creator “Projects” tab, you can view or change the build directory for each build kit. The build directory also contains files from previous builds, because this allows to speed up the build process as e.g. only new or changed files will be rebuilt. You can safely delete this build folder from your file system, as it will be created again with the next build.

    One other thing that might be relevant, is that for type or auto-completion issues, it can help to restart Qt Creator and reopen the project e.g. when you change a type-name, as Qt Creator then reloads all types and autocompletion data.

    Best,
    Günther

    #15099

    Todd

    Hey again Gunther…

    So I went in and deleted the files and re built/cleaned them.

    I still continue to get these errors:

    qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method

    qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method

    qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method

    qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method

    qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto

    qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb

    qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated

    qt.network.ssl: QSslSocket: cannot call unresolved function SSL_get0_next_proto_negotiated

    file:///C:/Users/todd/OneDrive/Company/qml/MainItem.qml:46:3: Type GameScene unavailable

    file:///C:/Users/todd/OneDrive/Company/qml/scenes/GameScene.qml:37:3: Type Level unavailable

    file:///C:/Users/todd/OneDrive/Company/qml/game/Level.qml:28:3: Bombs is not a type

    C:\Users\todd\OneDrive\Company\release\FlappyBird.exe exited with code 0

     

    Is it something with my code?

     

    #15100

    Todd

    And by the way I was working on this on both my desktop and laptop via onedrive, I dont see why it would be a problem but just thought I’d mention it.

    #15102

    Alex
    V-Play Team
    file:///C:/Users/todd/OneDrive/Company/qml/game/Level.qml:28:3: Bombs is not a type

    Again you are obviously using “Bombs” in your code while your qml files are named “Bomb

    #15106

    Todd

    Alex,

    I set it back to bomb but now I get these

    qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method

    qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method

    qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method

    qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method

    qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto

    qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb

    qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated

    file:///C:/Users/todd/OneDrive/Company/qml/MainItem.qml:46:3: Type GameScene unavailable

    file:///C:/Users/todd/OneDrive/Company/qml/scenes/GameScene.qml:37:3: Type Level unavailable

    file:///C:/Users/todd/OneDrive/Company/qml/game/Level.qml:28:3: Type Bomb unavailable

    file:///C:/Users/todd/OneDrive/Company/qml/entities/Bomb.qml:16:7: id is not unique

    qt.network.ssl: QSslSocket: cannot call unresolved function SSL_get0_next_proto_negotiated

    C:\Users\todd\OneDrive\Company\release\FlappyBird.exe exited with code 0

     

    The reason i set it to bombs is because of the flappy bird template has the same thing set as “pipes”

    #15107

    Günther
    V-Play Team

    Hi Todd!

    In the flappy bird game, the QML file is also named Pipes.qml (not Pipe.qml), which is why the name in QML is then Pipes.

    The new error

    file:///C:/Users/todd/OneDrive/Company/qml/entities/Bomb.qml:16:7: id is not unique
    suggests that at there are two items within Bomb.qml that use the same id, which is not allowed. Please choose another id for one of them, for example the id specified at line 16 in Bomb.qml.

    You can also have a look at our Getting Started with QML tutorial to learn more about the basic concepts.

    Best,
    Günther

    #15108

    Todd

    Thank you… yeah I’ve been looking through tutorials and such so I am learning.

    Now the game runs but the bombs don’t show up for me. :(

     

    Ill check out your link later today

    #15109

    Todd

    Update,

    I got it working Gunther, thank you for everything

Viewing 15 posts - 1 through 15 (of 15 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support