Runtime Revolution
 
Articles Other News

Using the New Features of Revolution 2.7.4 in a simple Sudoku application.

by Elanor Buchanan

This article will show how you can use the new features of 2.7.4 to improve on your existing programs and make building an application that will run on U3 drives even simpler.

Download the accompanying Sudoku application.

To learn how to make the application from scratch, look out for the latest copy of PCFormat, containing a full tutorial on building this Sudoku game.

The features we are demonstrating are:

Hover Icons
Multiline Tooltips
Proportional resizing
U3 Tutorial and Standalone Builder
Zip file building

We will start with a working, skinned Sudoku application and improve it using the new features available in Revolution 2.7.4.

1. Hover Icons

Hover icons allow objects to be hilited more easily when the mouse moves over them. This is a great feature to add to the game as it makes it clear which numbers on the board can be moved: you don't want to move the numbers that were given to you as a starting point as you know they are in the correct place.

All you need to do is set the hover icon of the draggable buttons on the left of the stack. This is a huge improvement, in previous versions if you wanted hover icons you would have had to manually script this for each button using mouseEnter and mouseLeave messages.

In our "Grid" group script we set the icon and the hover icon of the cell the number was dropped on so that it is clear which numbers can be moved around on the grid.

2. Multiline Tooltips

Another neat new feature of Revolution 2.7.4 is the ability to have multiline tooltips. Previously tooltips were limited to one line which could be awkward if you wanted to give your user a lot of information. Now tooltips can give more details allowing a better explanation of your interface. You just set the tooltip in the Object Inspector putting in new lines where you want them.

3. Proportional Resizing

Now - the size of this Sudoku game is quite large, if you have a 1024 x 768 monitor it takes up most of the screen. But Revolution now allows proportional resizing of objects so you can easily adjust the size of the background image and the buttons on the "images" card, by holding down shift while resizing using the handles. Remember to set the Resize Quality of the images to best and lock their size and position so they don't go back to their old sizes. Also remember to resize the cells in the grid and reposition the group in the correct place. You can resize the stack by reselecting the Window Shape and it will fit to the new size the the background image.

4. U3 Tutorial and Standalone Builder

It is very easy to build this Sudoku game for all platforms, we will build for MacOSX, Windows and U3. The only point you need to be careful of is making sure that the program can find the files it needs to set up the games. This is simple on Mac and Windows, you just need to include them next to the standalone but for a U3 application they must be included within the U3 package that is installed on the U3 drive. The Revolution Standalone builder makes this very easy. Just go to Standalone Application Settings, go to the Windows pane and select Advanced U3 settings. Add the Templates folder (containing text files describing start states and solutions) to the Data folder within the U3 package.

All we need to do then is ensure our templatePath function in the stack script returns the correct path. We do this using the U3 environment variables and a flag that is set on startup if the program is running on a U3 drive.

Revolution 2.7.4 includes a useful new tutorial on creating a U3 application. For more information on creating U3 applications and making them U3 compliant have a look at the U3 example in the Getting Started section of the Documentation.

5. Zip it up for Release

The final new feature of Revolution that we might want to use is revZip. You can write a short function to zip the program and template files up for distribution. This is not needed for U3 applications as they are a single file. In Revolution 2.7.4 the ability to cancel a zip operation was added, giving more flexibility of use. In the next issue of this newsletter we will be publishing a complete article on how to create and use your own Revolution zip file application for zipping up applications. Be sure not to miss it!

©2005 Runtime Revolution Ltd, 15-19 York Place, Edinburgh, Scotland, UK, EH1 3EB.
Questions? Email info@runrev.com for answers.