It's amazing how many blind alleys I enter when trying to program. Because I don't know how Lua or Corona really work I spend a lot of time and energy pursuing thoughts only to find, eventually, that I just can't get it to work that way. Spent the last two days trying to figure out how to enlarge a touch area. When I tried my game on my Android phone, the pieces were so small that it was very difficult to focus on them and drag them (or activate the bucket to pour the water). So I went to the forums and found something that might have worked: you put a larger, invisible rectangle in front of the small object. Worked great with the bucket, not so great with the boards that you drag to direct the falling water. I used display groups to link the rectangle and smaller object.
A group is like a bag and you can put your display objects into that bag so you can do things to all of the images at one time. It's a way to organize and a way to manipulate your display objects (images). Problem is, once you group them the physics engine in Corona doesn't work very well. So after I grouped the small board with the larger invisible rectangle, I could move them easily, but the water balls fell right through.
And that's when I tried different things. Tried to weld the two objects together. After wasting an hour or two I find out that you can only weld "dynamic" objects together. Well, a dynamic object reacts to the gravity of the physics engine, so the board and rectangle fall to "earth" and can't be moved to a specific area.
Then I took a detour through waste-your-time-ville and for some reason thought it would be a good idea to remove the physics from the target object. You see, I had the target object set up as a physics body so that when the water balls hit it I could have the object melt. That was working fine before, I have no idea why I decided it would be better to get rid of that. So I spent hours trying to make the code work in a way that it can't (or, more exactly, in a way that I don't know how to control it).
After a frustrating two days I find myself no further along. However, as others have said, there are no mistakes, only lessons to learn. I have learned more about coding and how Lua and how Corona work (and don't work). So that's something.
No comments:
Post a Comment