Forums

OverviewV-Play 2 Support (Qt 5) › Problems with colliding objects and a question about debugDraw

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9990

    Ben

    Hi there

    I am having some problems with colliding objects and I was wondering whether anyone could help me out?

    I am making a game based on the flappy bird example game, and somehow the gameOver call has stopped working in my modifications (the objects collide but nothing happens). I am using a box collider (obstacleCollider) to signal when the player hits the obstacle (obstacleSequence) (Code shown below). However I do know that the player.gameOver() function is working because it works for other collisions but not this one.

      BoxCollider {
        id: obstacleCollider
        height: obstacleSequence.height
        width: obstacleSequence.width
        anchors.centerIn: obstacleSequence
        bodyType: Body.Static
        collisionTestingOnlyMode: true
        fixture.onBeginContact: {
          player.gameOver()
        }
      }

    I can think of three reasons why this may not be working, and I was wondering whether these may be causing the described problems?

     

    1) I have changed the player sprite from what was in the flappy bird example to a spriteSequenceVPlay, and it might be possible that this means something else has to change?

     

    2) I receive this set of repeated error messages every time I run the game:

    qrc:///qml/VPlay/physics/ColliderBase.qml:94:25: Unable to assign [undefined] to bool

    qrc:///qml/VPlay/physics/ColliderBase.qml:377:13: Unable to assign [undefined] to bool

    qrc:///qml/VPlay/physics/ColliderBase.qml:94:25: Unable to assign [undefined] to bool

    qrc:///qml/VPlay/physics/ColliderBase.qml:377:13: Unable to assign [undefined] to bool

    Could this be the cause of my problems? Can anyone explain why this is happening?

     

    3) I noticed that when debugDraw is set to true, the boxCollider described above is shown as the green box (as usual) but unusually it does not have the purple square surrounding it. Is there a reason for this? When I stop the boxcollider from following the moving spriteSequenceVPlay (delete the line: anchors.centerIn: obstacleSequence) the purple box is visible and the gameOver function works.

     

    If anyone has any thoughts on any of this I would be very grateful to hear them

    Thanks in advance,

     

    Ben

     

     

     

    #9991

    Günther
    V-Play Team

    Hi Ben,

    Normally, there shouldn’t be any problem with using SpriteSequenceVPlay.

    As for the error messages: I believe this occurs because the collider expects to be a child within an EntityBase component. Do you maybe use the collider directly within SpriteSequence?

    SpriteSequenceVPlay {
      id: obstacleSequence
      // ...
      BoxCollider {
        // leads to error
      }
    }
    

     

    EntityBase {
      id: obstacleEntity
    
      SpriteSequenceVPlay {
        // ...
      }
    
      BoxCollider {
        // no errors
      }
    }

     

    This should at least clear up the error messages… Sadly, I cannot directly reproduce your error on my side (I always see the purple rectangle in DebugDraw and collision detection works fine). Did you change anything else in the code?

     

    Best,

    GT

     

    • This reply was modified 3 years, 3 months ago by  GT.
Viewing 2 posts - 1 through 2 (of 2 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