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

Forums

OverviewFelgo 1 Support › Problems with Grid

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #4274

    Saims

    Hi!

    In our baloon shooter game we sometimes need more than 50 baloons in our lvl, so we thought a grid with a repeater would be the perfect choice. Unfortunately with a grid the baloons won’t behave like they should, even if the grid/baloons itself get displayed correctly.
    e.g. they don’t pop when they get hit by an arrow, or collision-sounds/effects start even if you miss them.
    If we just add the baloons individually, everything works fine.

    So my questions. Why is that the case and what can I do, to make them behave correctly?
    Are there other ways, to comfortably add multiple entities (that behave correctly) in a certain shape? e.g. if I want 20 baloons that form a circle, or would I have to add every single baloon separately?

    That would be the code of our grid (nothing special):
    Grid {
    x: parent.width / 2.5; y: parent.height / 5
    rows: 6; columns: 10; spacing: 5

    Repeater {
    model: 60
    Baloon { }
    }
    }

    Cheers,
    Simon

    #4275

    Christian
    Felgo Team

    Hi Simon,

    the Grid, Column and Row elements are used for static objects only. If your balloons should move, you would need to create them from JavaScript code with the help of EntityManager. You can set the initial position for each entity from a for loop, like in the following example they are placed in the vertical center of the screen in a row:

    for(var i=0;i<5; i++) {
      entityManager.createEntityFromUrlWithProperties(Qt.resolvedUrl("entities/Balloon.qml"), {x: i*10, y: scene.height/2} );
    
    }

    Cheers, Chris

    #4276

    Saims

    Okay, thx. But I’m still having rather basic problems with qml and don’t really know where to put that JavaScript code. So I got my Level01.qml, where I add my entities, but where should that for-loop then be? In a function? And if yes, where would I implement and call that function?

    #4277

    Christian
    Felgo Team

    Hi,

    you would load the entities when you load your levels, i.e. when you start the game by pressing the play button in your menu. For debugging, you can also add the entities into a Component.onCompleted: { … }  block in your level, which is called when the QML item gets created. Please also see the Getting started with Felgo guide .  And also the existing demo games in the Felgo SDK folder help a lot to understand.

    Cheers, Chris

    #4278

    Saims

    Thank you, I’ll do that!

    Cheers,
    Simon

Viewing 5 posts - 1 through 5 (of 5 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