summaryrefslogtreecommitdiffstats
path: root/demos/declarative/samegame/content/samegame.js
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-07-23 05:28:46 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-07-23 05:28:46 (GMT)
commit1d1b32453519eb952438c734e21ae5ddf09e4966 (patch)
tree5db1593d0a2dd4f1fbee06875d114432eb572ae4 /demos/declarative/samegame/content/samegame.js
parentf8dff7351ede7ec032947e8d5b6c3268485a1da5 (diff)
downloadQt-1d1b32453519eb952438c734e21ae5ddf09e4966.zip
Qt-1d1b32453519eb952438c734e21ae5ddf09e4966.tar.gz
Qt-1d1b32453519eb952438c734e21ae5ddf09e4966.tar.bz2
Move the mouse control of the game from the main file to the blocks
This allows for spin on hover - note that the code to spin back is in there but not working at the moment.
Diffstat (limited to 'demos/declarative/samegame/content/samegame.js')
-rw-r--r--demos/declarative/samegame/content/samegame.js8
1 files changed, 2 insertions, 6 deletions
diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js
index 91d97d5..6bcfd17 100644
--- a/demos/declarative/samegame/content/samegame.js
+++ b/demos/declarative/samegame/content/samegame.js
@@ -50,10 +50,8 @@ var fillFound;
var floodBoard;
var lastHoveredIdx = -2
-function handleHover(x,y, btn)
+function handleHover(xIdx,yIdx, btn)
{
- xIdx = Math.floor(x/tileSize);
- yIdx = Math.floor(y/tileSize);
if(index(xIdx, yIdx) == lastHoveredIdx)
return;
lastHoveredIdx = index(xIdx, yIdx);
@@ -67,11 +65,9 @@ function handleHover(x,y, btn)
//Could use the fillFound value to tell the player how many stones/points
}
-function handleClick(x,y)
+function handleClick(xIdx,yIdx)
{
//NOTE: Be careful with vars named x,y - they can set to the calling object
- xIdx = Math.floor(x/tileSize);
- yIdx = Math.floor(y/tileSize);
if(xIdx >= maxX || xIdx < 0 || yIdx >= maxY || yIdx < 0)
return;
if(board[index(xIdx, yIdx)] == null)