Forums

OverviewV-Play 1 SupportBoxCollider › Re: BoxCollider

OverviewV-Play 1 SupportBoxCollider › Re: BoxCollider
#4126

Christian
V-Play Team

That’s a very good question!

The problem is, that after disabling the MouseArea, no onReleased gets called so you cannot re-enable it at that time. So I think it may be better to not disable it, but instead set the drag.target to another (temporary) item, and in onReleased set it back to your entity.

The code would look something like that:


import VPlay 1.0
import QtQuick 1.1

EntityBase {
  id: entity

  MouseArea {
    id: mouseArea
    anchors.fill: parent
    drag.target: entity

    onReleased: {
      // set it to the entity again, so it can be re-dragged
      mouseArea.drag.target = entity
    }
  }


  Item {
    // this gets only used to avoid dragging the entity when a collision occured
    id: temporaryDragTarget
  }

  BoxCollider {
    // ... your boxCollider information here ...

    fixture.onBeginContact: {
      // avoid dragging further, when a collision was reached
      mouseArea.drag.target = temporaryDragTarget
    }
  }
}

Cheers,
Chris

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