Forums

OverviewV-Play 2 Support (Qt 5)physics acceleration object over time › Reply To: physics acceleration object over time

OverviewV-Play 2 Support (Qt 5)physics acceleration object over time › Reply To: physics acceleration object over time
#11276

Bas

hi Alex,

 

thanx for that, but i need rotation of the ball (in fact it isn’t really a ball) so i turned friction on.

and there is only an initial force applied to the ball but when i alter some params i get the drunken ball again :)

 

import VPlay 2.0
import QtQuick 2.0

GameWindow {
  id: gameWindow
  activeScene: scene
  width: 960
  height: 640

  EntityManager {
    entityContainer: scene
  }

  Component.onCompleted: {
    ball.collider.applyLinearImpulse(Qt.point(20,14));
  }

  Scene {
    id: scene
    width: 480
    height: 320

    PhysicsWorld {

    }

    BoxCollider {
      width: 10
      height: parent.height
      bodyType: Body.Static
      anchors.right: parent.left
    }
    BoxCollider {
      width: 10
      height: parent.height
      bodyType: Body.Static
      anchors.left: parent.right
    }
    BoxCollider {
      width: parent.width
      height: 10
      bodyType: Body.Static
      anchors.bottom: parent.top
    }
    BoxCollider {
      width: parent.width
      height: 10
      bodyType: Body.Static
      anchors.top: parent.bottom
    }

    EntityBase {
      id: ball
      x: 50
      y: 50
      property alias collider: collider
      Rectangle {
        color: "#f00"
        width: 10
        height: 10
        radius: 5
        anchors.centerIn: parent
      }

      CircleCollider {
        id: collider
        radius: 5
        restitution: 1
        friction: 0.2
        density: 0.03
        bullet: true
        force: Qt.point(linearVelocity.x/10,linearVelocity.y/10)
        anchors.centerIn: parent
      }
    }
  }
}

 

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