GameView.qml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import QtQuick 1.0
  2. /*
  3. Game View ..this is where magic happens
  4. */
  5. Item {
  6. id: gameView
  7. opacity: 0
  8. property int counter: 0
  9. function addItemToList(word){
  10. gameWords.append({"word": word});
  11. }
  12. function clearList(){
  13. gameWords.clear();
  14. counter = 0
  15. youWin.opacity = 0
  16. }
  17. Column {
  18. id:wordColumn
  19. x: 18
  20. y: 75
  21. width: 331
  22. height: 478
  23. spacing: 34
  24. Repeater{
  25. model: gameWords
  26. delegate: gameWordDelegate
  27. }
  28. }
  29. ListModel {
  30. id: gameWords
  31. }
  32. Component {
  33. id: gameWordDelegate
  34. BorderImage{
  35. id: listItem
  36. height: 83
  37. width: 300
  38. property bool selected: false
  39. source: mouseArea3.pressed ? "qrc:/rectYellow" :"qrc:/rectBlue"
  40. border { left: 5; top: 5; right: 5; bottom: 5 }
  41. horizontalTileMode: BorderImage.Repeat
  42. verticalTileMode: BorderImage.Repeat
  43. x:25
  44. Text {
  45. id: wordText
  46. text: word
  47. anchors.centerIn: parent
  48. font.pixelSize: 24
  49. color: "white"
  50. }
  51. Image{
  52. id:coin
  53. source: "qrc:/coin"
  54. opacity: 0
  55. anchors.verticalCenter: parent.verticalCenter
  56. anchors.right: parent.right
  57. anchors.rightMargin: 10
  58. }
  59. MouseArea{
  60. id:mouseArea3
  61. anchors.fill: parent
  62. onClicked:{
  63. wordText.color = "white";
  64. listItem.source = "qrc:/rectGray";
  65. coin.opacity = 1;
  66. if( !selected ){
  67. selected = true;
  68. counter++;
  69. }
  70. if ( counter == 4 ) {
  71. youWin.opacity = 1;
  72. }
  73. }
  74. }
  75. }
  76. }
  77. Image {
  78. id: youWin
  79. opacity: 0
  80. source: "qrc:/youWin"
  81. MouseArea{
  82. anchors.fill: parent
  83. onClicked: {
  84. screen.state = "vocabularySelectionView";
  85. }
  86. }
  87. }
  88. }