![]() ![]() You can change the location of your projects/solutions. In case anyone is still looking for this, you set this in settings.json using the key 'git.defaultCloneDirectory'. Physics. Then, automatically, your default save location is exactly as youd like it to be. Table.insert( asteroidsTable, newAsteroid ) Local newAsteroid = display.newImageRect( mainGroup, objectSheet, 1, 102, 85 ) Basically, these can be copied over directly into your a file, pasted directly below the variables we just defined.įirst, copy over the updateText() function: local backGroupįollow this with the createAsteroid() function: local function updateText() So, instead of associating each variable with a display.newGroup(), just leave them undefined for the moment: local shipĪs we continue past this point in main_a, we come to the local functions which power our game's core functionality. However, we still need to define the variables now using the forward declaration method that you learned about earlier. To facilitate this, we will defer the actual creation of our three groups until we create the scene. Now, an important concept to understand is that display groups can actually be inserted into other display groups! As such, we can maintain the three display groups from the original game and instill them into the scene's view group. In the last chapter, you learned how to insert scene objects into the scene's view group ( sceneGroup). We are still going to use them, but a few small modifications will be necessary since we're using Composer. ![]() In our original version, we created three display groups for sorting and layering our game objects: backGroup, mainGroup and uiGroup. ![]() For instance, we already added commands to spawn asteroids and put them in motion, but in this a scene we're about to create, those commands will only run once the scene is fully on screen. The same approach applies to Composer scenes. Using it correctly requires that you consider the scene life cycle functions - scene:create(), scene:show(), scene:hide(), and scene:destroy() - and that you run commands depending on whether the scene is on screen or off screen.Ĭonsider this concept like a movie scene: if the director is transitioning into a scene - fading in, panning the camera to a point, etc. - the actors in the scene usually won't begin acting until the scene is "ready" and focused. In our original version of Star Explorer, we had the luxury of writing our code in a linear order, for example creating an object, positioning it on the screen, potentially adding a physical body, linking up event listeners, and then moving on to the next item.Ĭomposer requires that you think a little differently. As you learned in the previous chapter, there are dedicated places in a Composer-enabled Lua file to put different aspects of your program. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |