Tic Tac Toe [Lesson7]
[S1E16] LUA EVENT HANDLING & EVENT LISTENERS: How to program objects to respond to tap/touch events in Lua
So in this Solar 2D Lua Programming lesson, we look at how to firstly name an object, so that when we tap on it, we can identify specifically which of the 9 boxes was involved.
Then, we create a function that when an appropraite event occurs, it involkes the code (for now this is to print to the console the name of the box), but in future turoials we will get all sorts of funky things happening!
Finally once the box knows it's name, and an event function exists, we apply a "listener" to the box, so that it can call the function when invoked!
We also identify a logic problem, in the order of our code.
Lua reads top down and then executes any functions calledworking back up the scene code.
This means it can read in a function, knows it exists, ready for when it is called.
So for our event functions to work, we need the function to exist BEFORE the objects are created.
BUT, we need the objects to exist first so their creation code SITS inside of the SCENE CREATE section of code, when the function needs to sit later on in the SHOW DID.
So in the following tutorial, we will use an array to place our objects in, when we create them, then take them out later on to use them in the SHOW DID, and on doing so we can move the event function code to the correct place in our Lua Scene Template.
==== OPEN SOURCE & FREE ONLINE TOOLS ====
In my next few videos, I will look at these in more detail.
► Lua Website: [ Ссылка ]
► Solar2D (game engine): [ Ссылка ]
► Solar2D (aka Corona SDK) Documentation: [ Ссылка ]
==== SUBSCRIBE ====
► Please subscribe (& Stay NOTIFIED) to my channel - so you don't miss out:
[ Ссылка ]
► My other YouTube Channel McCall Media TV:
[ Ссылка ]
==== SERVICES USED TO MAKE/MENTIONED IN THIS VIDEO ====
► Streamyard: [ Ссылка ]
► Tubebuddy: [ Ссылка ]
► VidIQ: [ Ссылка ]
► Answer The Public: [ Ссылка ]
► Epidemic Sounds: [ Ссылка ]
► Envato Elements: [ Ссылка ]
==== VISIT MY WEBSITES ====
► [ Ссылка ]
► [ Ссылка ]
► [ Ссылка ]
==== VISIT MY SOCIAL PROFILES ====
♥ Facebook Business Page: [ Ссылка ]
♥ Instagram: instagram.com/pointclickpuzzlegames
♥ Patreon: [ Ссылка ]
==== HASHTAGS ====
#Variables
#LuaProgramming
#LuaCoding
#Solar2D
==== DISCLAIMER ====
Many of the links on this page are affiliate links, meaning if you were to make a purchase after using this link, then I would be paid a commission for that recommendation. However, I am in no way associated with the companies listed, please use your own judgement, and research before making a purchase. I use these links as a way to help fund my business, so I can continue to provide free content like this video. Your support is greatly appreciated.
Ещё видео!