Warning, /education/gcompris/src/activities/chess/Piece.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - chess.qml 0002 * 0003 * SPDX-FileCopyrightText: 2015 Bruno Coudoin <bruno.coudoin@gcompris.net> 0004 * 0005 * Authors: 0006 * Bruno Coudoin <bruno.coudoin@gcompris.net> (GTK+ version) 0007 * Bruno Coudoin <bruno.coudoin@gcompris.net> (Qt Quick port) 0008 * 0009 * SPDX-License-Identifier: GPL-3.0-or-later 0010 */ 0011 import QtQuick 2.12 0012 0013 Image { 0014 id: piece 0015 property int pos 0016 Behavior on opacity { PropertyAnimation { easing.type: Easing.InOutQuad; duration: 200 } } 0017 Behavior on x { PropertyAnimation { easing.type: Easing.InOutQuad; duration: items.noPieceAnimation ? 0 : 200 } } 0018 Behavior on y { PropertyAnimation { easing.type: Easing.InOutQuad; duration: items.noPieceAnimation ? 0 : 200 } } 0019 z: 10 0020 0021 property string img 0022 property bool acceptMove: false 0023 property int newPos 0024 // color = -1 if no piece, 0 is black and 1 is white 0025 property int isWhite: img.length != 2 ? -1 : img[0] == 'w' ? 1 : 0 0026 0027 0028 SequentialAnimation { 0029 id: hideAnim 0030 NumberAnimation { 0031 target: piece 0032 property: "scale" 0033 duration: 200 0034 to: 0 0035 } 0036 PropertyAction { 0037 target: piece 0038 property: 'img' 0039 value: "" 0040 } 0041 PropertyAction { 0042 target: piece 0043 property: 'pos' 0044 value: piece.newPos 0045 } 0046 PropertyAction { 0047 target: piece 0048 property: 'scale' 0049 value: 1 0050 } 0051 PropertyAction { 0052 target: piece 0053 property: 'z' 0054 value: 2 0055 } 0056 } 0057 0058 SequentialAnimation { 0059 id: promotionAnim 0060 PauseAnimation { 0061 duration: 200 0062 } 0063 NumberAnimation { 0064 target: piece 0065 property: 'scale' 0066 to: 0 0067 } 0068 PropertyAction { 0069 target: piece 0070 property: 'img' 0071 value: isWhite ? 'wq' : 'bq' 0072 } 0073 NumberAnimation { 0074 target: piece 0075 property: 'scale' 0076 to: 1 0077 easing.type: Easing.OutElastic 0078 } 0079 } 0080 0081 function hide(newPos) { 0082 piece.newPos = newPos 0083 hideAnim.start() 0084 } 0085 0086 function promotion() { 0087 promotionAnim.start() 0088 } 0089 0090 function move(to) { 0091 piece.newPos = to 0092 piece.pos = to 0093 piece.z = 2 0094 } 0095 } 0096