I’m already at a roadblock as the inhidingVariable exercise is not working (p.23 & 24). I’ve tried it a few different ways but Corona keeps giving me a trace back nil value & something about main chunk. I believe this would be simpler if we were shown where to type each code fragment/ create new file. I’ve seen other tutorials do this step by step and works well.
Also, just got to the download class.lua part. How is this done?
I’m terribly sorry that you’ve had problems with that part of the book.
The section you mentioned is probably the most confusing example in the chapter – I’ll have to rewrite some of the explanations in the next update. The project is made up of two different files: main.lua and hidingvariable.lua. Main.lua needs three of the code blocks from the chapter, and they have to be written in the order that they appear in the chapter. The other file uses the remaining code fragment (the code that sets the variable to “local”).
Each code fragment has its file name above it, so that will hopefully make it easier to check/compare with the book’s code files (instead of having to type each of the examples). You can download the book’s code files here: http://pragprog.com/titles/sdcorona/source_code.
You’ll get class.lua and most of the book’s other projects in that file. Class.lua is also listed in Appendix 2, but it’s much easier to download it.
If you wish, you can attach the file that you’ve been working on, and I can try to help with it.
I’m working through the book; on page 31, adding the background image … and there’s no indiation where the two lines of code go in game.lua.
I’m sorry that I skipped mentioning where to add the image! I hadn’t noticed that some of the codes in that chapter are written without mentioning where to add them.
You can add the image loading code to the game scene file (game.lua). To add it when the scene is created, add it to the scene:createScene() function.
I’ll have to re-read that chapter to make sure that it mentions where to write the rest of the code snippets. Thanks for noticing it.
It’s been my main concern reading the book (alas, away from my computer, so I can’t work through the exercises). To deliver on the promise of the book, I think every bit of code that is necessary should be presented, with enough context to know where it goes and why. I do not think it is nearly at that point.
|You must be logged in to comment|