Is this bad Programming/Coding?

Hello Everyone, 

I recently started learning Lua, got the hang of it on the second day of studying the documentation and practicing/testing certain things. 

I am what I call myself, a lazy programmer at most times. Mainly because I would program/code things in a harder way that I find easier because I don’t know or understand the actual way to do it. 

For example with HTML and JavaScript, I just use divs and a simple js function to show and hide certain things with onclicks and whatnot rather than having separate html files for each thing. 

My question is, is it bad that I would rather do stuff like this

example, say I had a menu screen made
 

local function onbuttonTouch(event)

   if(event.phase == “began”) then
            Menu.isVisible = false

            Option1.isVisible = false 
             Option2.isVisible = false 
           // this being like each option or thing on the menu
            game.isVisible = true

is it bad to say have this rather than using scenes? I am trying to comprehend scenes and honestly it makes sense mentally, but codingwise it isn’t working. 

As I typed this though I realized I could probably just group everything in my menu then just do 

group.isVisible = false 

if that is possible to do, I will find out. 

few other random questions too

why are gifs not supported? Instead you have to use imagesheets which honestly isn’t that all pretty

Sometimes my android deletes the previous apk I made on there, for example, I would make a game, install the apk but if i had another game that I made, it would delete it. Not sure if this is an issue I can fix. 

Thanks everyone!

Hi @aj_viens_deruisseau,

Welcome! The example you give would be better if you inserted all of the objects into a group, then toggled the visibility of the entire group on/off. It’s less lines of code and much easier to manage if the elements (children) of that group change as your development moves along.

On scenes, did you go through the “Star Explorer” project in our Getting Started guide? That covers scenes in a fair amount of detail a few chapters in, and (I hope) in a user-friendly manner. As you move forward with Corona, scenes will become a very important aspect of your games, so it’s probably a good idea to start learning about them now. :slight_smile:

https://docs.coronalabs.com/guide/programming/02/index.html

For images, you don’t necessarily need to use image sheets. You can use individual .PNG or .JPG files. However, image sheets are often a better way to group/organize sets of images, and they’re very memory-friendly.

Have fun!

Brent

Hey! Well, going through scenes would be much more efficient. Are you trying to do like a layover menu that sits on the home screen? One way or another just switching scenes and disposing of the previous in the right manner would save on memory and simply look better in the code. 

Not sure why gifs aren’t supported…

On android if you have an app on your phone with the name “coronalabs” and you try to install another app called “coronalabs” it will overwrite it(so delete and reinstall). So it’s not an issue. :slight_smile:

Also, being a lazy programmer isn’t going to get you very far lol. 

Good luck working in Corona! It’s easy and a very powerful tool!

First Lazy programmers make the best programmers IMHO because they tend to write more concise code. They tend to adhere to DRY (Don’t Repeat Yourself) principles. They tend to come up with the most efficient code.  Of course there are drawbacks to being a lazy programmer. Long variable names are evil to lazy programmers, but a necessary evil. I was working on something last night and my variables are q, r, c, px and such. I of course can’t ever show anyone this code until I change the variables to something readable.

GIFs are more complex than you think. We would basically have to read it, pull each frame out into an in-memory sprite sheet and then through the OpenGL pipeline.  There is a plugin that will load and save GIF’s but I’ve never used it. You can research it here:

https://marketplace.coronalabs.com/plugin/impack

The app deletion issue is based on the Package ID, your com.yourdomain.yourappname string that you provide. That has to be unique. If you want multiple apps, simply change that name in the build.screen.

Finally on your main point. Back when I was working on what would be my first released game, I had no clue about scene management. At that time we had the Director class that was a 3rd party/community created scene manager that was around before we created Storyboard, our first official scene manager. Today it’s Composer (which is really Storyboard 2.0)

I can tell you from personal experience, I wish I would have spent the extra time and learned scene management rather than creating my own. That game is very hard to maintain and I was doing the basic showing/hiding of display groups.  Brent is right, if you go that route, put everything that belongs together into a group so you can show/hide the group instead of each individual object.

Rob 

oh funny- i did this exact same thing when i started! i made a dressup app and made everything invisible, then turned things visible and invisible depending on what was needed. it worked fine on the computer but when i put the app on the device it really slowed down a lot- having all those images in its memory was making it really laggy. so i had to work with memory management a bit more, do scenes, and make sure i was only using the images i needed, and tossing out the rest instead of having them all active at once (just invisible).

anyway i did spend a bit learning about scenes, i’m not a master but if you work with the tutorial for an hour or so you should get the hang of it. it might be a pain now but might make things easier later on. https://docs.coronalabs.com/guide/system/composer/index.html

you can also do animation with spine by esoteric, it’s a great program > http://esotericsoftware.com/

good luck :slight_smile:

Hi @aj_viens_deruisseau,

Welcome! The example you give would be better if you inserted all of the objects into a group, then toggled the visibility of the entire group on/off. It’s less lines of code and much easier to manage if the elements (children) of that group change as your development moves along.

On scenes, did you go through the “Star Explorer” project in our Getting Started guide? That covers scenes in a fair amount of detail a few chapters in, and (I hope) in a user-friendly manner. As you move forward with Corona, scenes will become a very important aspect of your games, so it’s probably a good idea to start learning about them now. :slight_smile:

https://docs.coronalabs.com/guide/programming/02/index.html

For images, you don’t necessarily need to use image sheets. You can use individual .PNG or .JPG files. However, image sheets are often a better way to group/organize sets of images, and they’re very memory-friendly.

Have fun!

Brent

Hey! Well, going through scenes would be much more efficient. Are you trying to do like a layover menu that sits on the home screen? One way or another just switching scenes and disposing of the previous in the right manner would save on memory and simply look better in the code. 

Not sure why gifs aren’t supported…

On android if you have an app on your phone with the name “coronalabs” and you try to install another app called “coronalabs” it will overwrite it(so delete and reinstall). So it’s not an issue. :slight_smile:

Also, being a lazy programmer isn’t going to get you very far lol. 

Good luck working in Corona! It’s easy and a very powerful tool!

First Lazy programmers make the best programmers IMHO because they tend to write more concise code. They tend to adhere to DRY (Don’t Repeat Yourself) principles. They tend to come up with the most efficient code.  Of course there are drawbacks to being a lazy programmer. Long variable names are evil to lazy programmers, but a necessary evil. I was working on something last night and my variables are q, r, c, px and such. I of course can’t ever show anyone this code until I change the variables to something readable.

GIFs are more complex than you think. We would basically have to read it, pull each frame out into an in-memory sprite sheet and then through the OpenGL pipeline.  There is a plugin that will load and save GIF’s but I’ve never used it. You can research it here:

https://marketplace.coronalabs.com/plugin/impack

The app deletion issue is based on the Package ID, your com.yourdomain.yourappname string that you provide. That has to be unique. If you want multiple apps, simply change that name in the build.screen.

Finally on your main point. Back when I was working on what would be my first released game, I had no clue about scene management. At that time we had the Director class that was a 3rd party/community created scene manager that was around before we created Storyboard, our first official scene manager. Today it’s Composer (which is really Storyboard 2.0)

I can tell you from personal experience, I wish I would have spent the extra time and learned scene management rather than creating my own. That game is very hard to maintain and I was doing the basic showing/hiding of display groups.  Brent is right, if you go that route, put everything that belongs together into a group so you can show/hide the group instead of each individual object.

Rob 

oh funny- i did this exact same thing when i started! i made a dressup app and made everything invisible, then turned things visible and invisible depending on what was needed. it worked fine on the computer but when i put the app on the device it really slowed down a lot- having all those images in its memory was making it really laggy. so i had to work with memory management a bit more, do scenes, and make sure i was only using the images i needed, and tossing out the rest instead of having them all active at once (just invisible).

anyway i did spend a bit learning about scenes, i’m not a master but if you work with the tutorial for an hour or so you should get the hang of it. it might be a pain now but might make things easier later on. https://docs.coronalabs.com/guide/system/composer/index.html

you can also do animation with spine by esoteric, it’s a great program > http://esotericsoftware.com/

good luck :slight_smile: