main.qml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import Qt 4.7
  2. import QtQuick 1.0
  3. //import QtMultimediaKit 1.1
  4. import "script.js" as Logic
  5. Rectangle {
  6. id:container
  7. width: 640
  8. height: 270
  9. property bool tick: false
  10. property bool isMenuOpen: false
  11. property bool colorButton: true
  12. function showMenu()
  13. {
  14. menuitem1.x = 440
  15. menuitem1.y = 10
  16. menuitem2.x = 400
  17. menuitem2.y = 100
  18. menuitem3.x = 440
  19. menuitem3.y = 190
  20. isMenuOpen = !isMenuOpen
  21. }
  22. function hideMenu()
  23. {
  24. menuitem1.x = 900
  25. menuitem1.y = 130
  26. menuitem2.x = 900
  27. menuitem2.y = 130
  28. menuitem3.x = 900
  29. menuitem3.y = 130
  30. isMenuOpen = !isMenuOpen
  31. }
  32. // Audio {
  33. // id: playMusic
  34. // source: "d:\\move.wav"
  35. // volume: 1.0
  36. // }
  37. // Game Field Mouse Area
  38. MouseArea {
  39. id: mouse_area1
  40. anchors.fill: parent
  41. x: 78
  42. y: -2
  43. width: 310
  44. height: 300
  45. anchors.topMargin: -2
  46. anchors.leftMargin: 78
  47. z: 2
  48. anchors.rightMargin: 252
  49. anchors.bottomMargin: 2
  50. onClicked:
  51. {
  52. Logic.step(mouse.x, mouse.y);
  53. //playMusic.play();
  54. }
  55. }
  56. // Menu show/hide button
  57. Image {
  58. id: image2
  59. x: 0
  60. y: -5
  61. width: 640
  62. height: 270
  63. source: "Back.png"
  64. Image {
  65. id: image1
  66. x: 495
  67. y: 90
  68. source: "st1.png"
  69. SequentialAnimation {
  70. running: true
  71. PropertyAnimation { target: image1; property: "source"; to: "st2.png"; duration: 200 }
  72. PropertyAnimation { target: image1; property: "source"; to: "st3.png"; duration: 200 }
  73. PropertyAnimation { target: image1; property: "source"; to: "st4.png"; duration: 200 }
  74. PropertyAnimation { target: image1; property: "source"; to: "st3.png"; duration: 200 }
  75. PropertyAnimation { target: image1; property: "source"; to: "st2.png"; duration: 200 }
  76. PropertyAnimation { target: image1; property: "source"; to: "st1.png"; duration: 200 }
  77. loops: Animation.Infinite
  78. }
  79. }
  80. MouseArea {
  81. id: mouse_area2
  82. x: 500
  83. y: 93
  84. width: 133
  85. height: 80
  86. z: 5
  87. onClicked:
  88. {
  89. if (!isMenuOpen)
  90. {
  91. showMenu()
  92. } else
  93. {
  94. hideMenu()
  95. }
  96. }
  97. }
  98. }
  99. MenuItem
  100. {
  101. id: menuitem1
  102. x: 900
  103. y: 150
  104. onClicked:
  105. {
  106. Logic.newGame(false)
  107. hideMenu()
  108. }
  109. z: 5
  110. }
  111. MenuItem
  112. {
  113. id: menuitem2
  114. x: 900
  115. y: 150
  116. srcPic: "pvi.png"
  117. onClicked: { Logic.newGame(true); hideMenu(); }
  118. z: 5
  119. }
  120. MenuItem
  121. {
  122. id: menuitem3
  123. x: 900
  124. y: 150
  125. srcPic: "exit.png"
  126. onClicked: { Qt.quit() }
  127. z: 5
  128. }
  129. }