Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 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
    Felgo 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 8 years, 8 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.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded