Ask Gary: Repositioning Word Search
enjoying the book, and probably ahead of myself BUT, how can I change
where the wordsearch grid and wordlist appear on the stage if I change the
size of the stage?
I've made the stage larger, and I would like to put the grid and wordlist
in the center - how do I change the X/Y?
thanks...
skillspider
There are many ways to do this. One would be to change some constants in the code. If you look at the start of the script, you will see an offset for the letter grid.
You can simply change this to 115,115 to move the grid to the right 100 pixels and down 100 pixels.
Similarly, you can move the word list over by changing this line:
What I would do first, is to make it dependent on the same offset constant. So change it to this:
Now it will always be to the right of the letter grid. All you need to do is change the offset constant to move both elements.
Another way to do this would be to simply move the gameDprite. Every game element is in the gameSprite, which is at position 0,0 by default. So moving it to 100,100 will have the same effect as the other changes. Here is that code inserted into the startWordSearch function.
gameSprite = new Sprite();
gameSprite.x = 100;
gameSprite.y = 100;
addChild(gameSprite);
- Flash Game University Blog
- Login or register to post comments
Copyright Gary Rosenzweig
