diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-11-20 01:57:07 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-11-20 01:57:07 (GMT) |
commit | 9b4b6301803cacd288547f8de1fd0370afd83ee3 (patch) | |
tree | 0ede92d2b58bbd47293cb5438407295e3d4bb79d /doc/src/declarative/advtutorial3.qdoc | |
parent | c771dd1e4a84108e3c345cf2696a6bb4a3aa4157 (diff) | |
download | Qt-9b4b6301803cacd288547f8de1fd0370afd83ee3.zip Qt-9b4b6301803cacd288547f8de1fd0370afd83ee3.tar.gz Qt-9b4b6301803cacd288547f8de1fd0370afd83ee3.tar.bz2 |
Doc tweaks
Minor touchups for the samegame tutorial
Diffstat (limited to 'doc/src/declarative/advtutorial3.qdoc')
-rw-r--r-- | doc/src/declarative/advtutorial3.qdoc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/doc/src/declarative/advtutorial3.qdoc b/doc/src/declarative/advtutorial3.qdoc index 0d236e4..5ac1be3 100644 --- a/doc/src/declarative/advtutorial3.qdoc +++ b/doc/src/declarative/advtutorial3.qdoc @@ -44,7 +44,7 @@ \example declarative/tutorials/samegame/samegame3 \title Advanced Tutorial 3 - Implementing the Game Logic -To the \c initBoard function we added clearing the board beforehand, so that clicking new game won't leave the previous game +First we add to the \c initBoard function clearing of the board before filling it up again, so that clicking new game won't leave the previous game lying around in the background. To the \c createComponent function we have added setting the type of the block to a number between one and three - it's fundamental to the game logic that the blocks be different types if you want a fun game. @@ -58,33 +58,33 @@ The main change was adding the following game logic functions: \endlist As this is a tutorial about QML, not game design, these functions will not be discussed in detail. The game logic here -was written in script, but it could have been written in C++ and had these functions exposed just as well (in fact, probably faster). -The interfacing between these funcions and QML is of interest though. Of these functions, only \c handleClick and \c victoryCheck +was written in script, but it could have been written in C++ and had these functions exposed in the same way (except probably faster). +The interfacing of these functions and QML is what we will focus on. Of these functions, only \c handleClick and \c victoryCheck interface closely with the QML. Those functions are shown below (the rest are still in the code for this tutorial located at \c{$QTDIR/examples/declarative/tutorials/samegame}). \snippet declarative/tutorials/samegame/samegame3/samegame.js 1 \snippet declarative/tutorials/samegame/samegame3/samegame.js 2 -You'll notice them referring to the \c gameCanvas item. This is an item that has been added to the QML for easy interfacing. +You'll notice them referring to the \c gameCanvas item. This is an item that has been added to the QML for easier interfacing with the game logic. It is placed next to the background image and replaces the background as the item to create the blocks in. Its code is shown below: \snippet declarative/tutorials/samegame/samegame3/samegame.qml 1 This item is the exact size of the board, contains a score property, and a mouse region for input. -The blocks are now created as its children, and its size is used to determining the board size. +The blocks are now created as its children, and its size is used to determining the board size, so as to scale to the available screen size. Since it needs to bind its size to a multiple of \c tileSize, \c tileSize needs to be moved into a QML property and out of the script file. -It can still be accessed from the script. +Note that it can still be accessed from the script. The mouse region simply calls \c{handleClick()}, which deals with the input events. Should those events cause the player to score, \c{gameCanvas.score} is updated. The score display text item has also been changed to bind its text property to \c{gamecanvas.score}. Note that if score was a global variable in the \c{samegame.js} file you could not bind to it. You can only bind to QML properties. -\c victoryCheck() mostly just updates score. But it also pops up a dialog saying \e {Game Over} when the game is over. +\c victoryCheck() primarily updates the score variable. But it also pops up a dialog saying \e {Game Over} when the game is over. In this example we wanted a pure-QML, animated dialog, and since QML doesn't contain one, we wrote our own. -Below is the code for the \c Dialog element, note how it's designed so as to be quite usable imperatively from within the script file: +Below is the code for the \c Dialog element, note how it's designed so as to be usable imperatively from within the script file (via the functions and signals): \snippet declarative/tutorials/samegame/samegame3/Dialog.qml 0 @@ -107,7 +107,7 @@ And the code for the block: \snippet declarative/tutorials/samegame/samegame3/Block.qml 0 -The game works, but it's a little boring right now. Where's the smooth animated transitions? Where's the high scores? +The game works, but it's a little boring right now. Where are the smooth animated transitions? Where are the high scores? If you were a QML expert you could have written these in for the first iteration, but in this tutorial they've been saved until the next chapter - where your application becomes alive! |