Commit 400ee167 authored by Bruno Coudoin's avatar Bruno Coudoin
Browse files

explore_farm_animals, simplified Animal item

parent ea84fbcf
......@@ -26,18 +26,16 @@ import GCompris 1.0
import "../../core"
import "explore.js" as Activity
Item {
id: animal
Image {
id: animalImg
width: animalWidth
height: animalHeight
property string animalSource
property real xA: xA
property real yA: yA
sourceSize.width: width
sourceSize.height: height
fillMode: Image.PreserveAspectFit
property string name: name
property real animalWidth: animalWidth
property real animalHeight: animalHeight
property alias starVisible: star.visible
property int questionId
property string title
property string description
......@@ -47,67 +45,53 @@ Item {
signal displayDescription(variant animal)
Image {
id: animalImg
source: parent.animalSource
sourceSize.width: parent.width
sourceSize.height: parent.height
x: xA
y: yA
fillMode: Image.PreserveAspectFit
SequentialAnimation {
id: anim
running: true
loops: 1
SequentialAnimation {
id: anim
running: true
loops: 1
NumberAnimation {
target: animalImg
property: "rotation"
from: 0; to: 360
duration: 400 + Math.floor(Math.random() * 400)
easing.type: Easing.InOutQuad
}
NumberAnimation {
target: animalImg
property: "rotation"
from: 0; to: 360
duration: 400 + Math.floor(Math.random() * 400)
easing.type: Easing.InOutQuad
}
}
Image {
id: star
x: animalImg.width / 2.5
y: animalImg.height * 0.8
visible: false
Image {
id: star
source:"qrc:/gcompris/src/core/resource/star.png"
}
x: animalImg.width / 2.5
y: animalImg.height * 0.8
visible: false
MultiPointTouchArea {
id: touchArea
anchors.centerIn: parent
// Make the item big enough to be clicked easily
width: Math.max(parent.width, 70 * ApplicationInfo.ratio)
height: Math.max(parent.height, 70 * ApplicationInfo.ratio)
touchPoints: [ TouchPoint { id: point1 } ]
mouseEnabled: true
source:"qrc:/gcompris/src/core/resource/star.png"
}
property bool started
MultiPointTouchArea {
id: touchArea
anchors.centerIn: parent
// Make the item big enough to be clicked easily
width: Math.max(parent.width, 70 * ApplicationInfo.ratio)
height: Math.max(parent.height, 70 * ApplicationInfo.ratio)
touchPoints: [ TouchPoint { id: point1 } ]
mouseEnabled: true
onStartedChanged: started ? retouch.start() : retouch.stop()
onPressed: {
var questionTargetId = items.questionOrder[Activity.items.score.currentSubLevel]
Activity.items.instruction.visible = false
if (Activity.items.currentLevel == 0) {
audioEffects.play(animal.audio);
displayDescription(animal)
star.visible = true;
onPressed: {
var questionTargetId = items.questionOrder[Activity.items.score.currentSubLevel]
Activity.items.instruction.visible = false
if (Activity.items.currentLevel == 0) {
audioEffects.play(animalImg.audio);
displayDescription(animalImg)
star.visible = true;
} else {
if (questionId === questionTargetId) {
animWin.start();
items.bonus.good("smiley");
Activity.nextSubLevel();
} else {
if (questionId === questionTargetId) {
animWin.start();
items.bonus.good("smiley");
Activity.nextSubLevel();
} else {
items.bonus.bad("smiley")
}
items.bonus.bad("smiley")
}
}
}
......
......@@ -117,11 +117,11 @@ ActivityBase {
model: dataset.tab.length
Animals {
questionId: index
animalSource: dataset.tab[index].image
xA: background.playX + background.playWidth * dataset.tab[index].x - animalWidth / 2
yA: background.playY + background.playHeight * dataset.tab[index].y - animalHeight / 2
animalWidth: background.playWidth * dataset.tab[index].width * background.playRatio
animalHeight: background.playHeight * dataset.tab[index].height * background.playRatio
source: dataset.tab[index].image
x: background.playX + background.playWidth * dataset.tab[index].x - width / 2
y: background.playY + background.playHeight * dataset.tab[index].y - height / 2
width: background.playWidth * dataset.tab[index].width * background.playRatio
height: background.playHeight * dataset.tab[index].height * background.playRatio
title: dataset.tab[index].title
description: dataset.tab[index].text
imageSource: dataset.tab[index].image2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment