MultiplayerDemo
import Felgo 3.0
import QtQuick 2.0
Item {
id: clock
width: 120
height: frame.height + display.contentHeight + display.anchors.topMargin
property int time
property bool twelve: time % 12 == 0
property bool day: time > 6 && time <= 18
property color sky: getSkyColor()
Image {
id: frame
width: parent.width
height: width
source: "../../assets/img/Clock.png"
}
Rectangle {
id: needle
height: frame.height / 2
width: 6
color: "black"
transformOrigin: Item.Bottom
x: frame.width/2 - width/2
y: 0
rotation: 30 * time
Behavior on rotation {
RotationAnimation { duration: 400; direction: RotationAnimation.Clockwise}
}
}
Text {
id: display
text: time + ":00"
anchors.horizontalCenter: parent.horizontalCenter
anchors.top: frame.bottom
anchors.topMargin: 5
font.pixelSize: 18
font.bold: true
}
function addTime(add){
var newTime = time + add;
newTime %= 24;
setTime(newTime)
if (twelve)
gConsole.printLn("It turned twelve o'clock thanks to " + multiplayer.activePlayer.name)
}
function setTime(newTime){
time = newTime
}
function getSkyColor(){
var dayColor = "#9fedec"
var noonColor = "#d7f8fc"
var nightColor = "#8aa5c5"
var midnightColor = "#5d80ac"
if (twelve){
return day ? noonColor : midnightColor
}else{
return day ? dayColor : nightColor
}
}
function reset(){