OverviewV-Play 1 SupportFound Bug? (EntityManager) › Re: Found Bug? (EntityManager)

OverviewV-Play 1 SupportFound Bug? (EntityManager) › Re: Found Bug? (EntityManager)


Hi everyone,

maybe i stumbled upon the same / a related problem with the EntityManager as I get a similar Warning when trying to delete a dynamically created entity. The following source creates an entity and removes it after two seconds. Afterwards a fresh entity is created and so on.


import VPlay 1.0
import QtQuick 1.1
import Box2D 1.0 // for accessing the Body.Static type

GameWindow {
  activeScene: scene
  width: 960
  height: 640

  EntityManager {
    id: entityManager
    entityContainer: scene
  Scene {
    id: scene
    width: 480
    height: 320

    function killCrate(){


    function spawnCrate(){
      var xPos = Math.random() * scene.width
      xPos = Math.max(50, Math.min(scene.width - 50, xPos))
      var yPos = 50

      var props = {
        x: Math.max(50, Math.min(scene.width - 50, Math.random() * scene.width)),
        y: 50,
        width: 30,
        height: 30
      var crate = entityManager.createEntityFromUrlWithProperties(Qt.resolvedUrl("Crate.qml"), props);


    function displayNumCrates(){
      var crates = entityManager.getEntityArrayByType("crate")
        debugText.text = crates.length

    Component.onCompleted: {
      id: creationTimer
      interval: 10
      onTriggered: scene.spawnCrate()
      repeat: false
      running: false

      id: deletionTimer
      interval: 2000
      onTriggered: scene.killCrate()
      repeat: true
      running: false

    PhysicsWorld {
      id: physicsWorld
      height: parent.height
      updatesPerSecondForPhysics: 60
      velocityIterations: 5
      positionIterations: 5
      gravity.y: -0.81
      running: true
    }// physicsWorld

    Rectangle {
      id: backgroundRectangle
      anchors.fill: parent
      color: "grey"
      z: -10

    Text {
      id: debugText
      anchors.right: parent.right
      width: 50
      height: 10
      color: "red"

  } // scene


import QtQuick 1.1
import VPlay 1.0
import Box2D 1.0 // for accessing the Body.Static type

EntityBase {
  id: entityBase
  entityType: "crate"
  transformOrigin: Item.TopLeft

  BoxCollider {
    anchors.fill: parent
    bodyType: Body.Dynamic

    Rectangle {
      color: "black"
      anchors.fill: parent

The disease pattern:
Every second crate survives removeAllEntities(). In the top right corner the number of managed crates is displayed (always “1” although two crates are temporarily visible).

The workaround:
The problem seems to stem from the direct recreation of the entity after removing the previous one. As a workaround, you can try to change the killCrate() function to the following:


Now the new entity is created after a short pause and everything works as expected.

I hope the above showcases Hochi’s problem. Anyway the observed behavior is somehow strange…


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
create apps
create games
cross platform
native performance
3rd party services
game network
level editor
easiest to learn
biggest time saving
best support