Advertisement
Guest User

Untitled

a guest
Dec 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.28 KB | None | 0 0
  1. import QtQuick 2.9
  2. import QtQuick.Window 2.3
  3. import QtQuick.Controls 2.4
  4. import Bacon2D 1.0
  5.  
  6.  
  7. ApplicationWindow {
  8.     id: window
  9.     height: 640
  10.     width: 480
  11.     visible: true
  12.     Game {
  13.         id: game
  14.         anchors.fill: parent
  15.         currentScene: scene
  16.         visible: true
  17.         anchors.centerIn: parent
  18.        
  19.         Settings {
  20.             id: settings
  21.             property int highScore: 0
  22.             property bool noSound: false
  23.         }
  24.        
  25.         Scene {
  26.             id: scene
  27.             physics: true
  28.             width: parent.width
  29.             height: parent.height
  30.            
  31.             Entity {
  32.                 width: parent.width
  33.                 height: parent.height
  34.                 updateInterval: 50
  35.                 behavior: ScriptBehavior {
  36.                     script: {
  37.                         var newPos = entity.x + 5
  38.                         entity.x = newPos > scene.width ? 0 : newPos
  39.                         console.log("update: x -> ", entity.x)
  40.                     }
  41.                 }
  42.                
  43.                 Rectangle {
  44.                     id: entity
  45.                     width: 50
  46.                     height: 50
  47.                     color: "red"
  48.                 }
  49.             }
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement