Back
BYU LiveCode Lessons Gateway
Side Scroller steps
Using the same basic game loop framework as we used for the "blastoff" stack, we can modify the image assets and the card's updateScreen
handler to create a very different animation. In the DigHT 310 file server, get the SideScroller folder in the lesson_materials/Time_and_timing/GameLoop folder, which should contain all of the required image and audio files. This is how we built the stack:
-
Create a new Stack for a tablet landscape layout (1024 X 748)
name the stack: sideScroller
-
Import these images to use as background images;
- mountbakerpanoramic-tall.png
- sun.png
-
Set the Resize quality of the imported images to Good
-
Resize and position the imported background images
(Mount Baker image should be resized to the same width as the screen, anchored to topLeft corner. It will not reach to the bottom of card.)
-
Lock size and position of the background images.
- Import images roadway.png and roadway2.png. These will become the panels for the scrolling background.
- simplify the image names to "road1" and "road2"
- set resizeQuality to Good
- proportionally resize them so that they are exactly the width of the card. Both images should be exactly the same height and width
- position them so that the bottoms of both images are at the bottom of the card
- lock size and position of both images
-
Import auto image "roadster.png"
- set resize quality to Good, resize as desired, lock size and position
-
Make a button for the car. Use the imported image as its icon. Do it in the property inspector or message box command:
set the icon of btn "car" to "roadster.png"
- There is a little-known property of objects that can make it more efficient for LiveCode to redraw them when they are being animated, called
layerMode
. Because the car and road objects will be moving, set their layerMode
to "dynamic":
set the layerMode of img "road1" to "dynamic"
set the layerMode of img "road2" to "dynamic"
set the layerMode of btn "car" to "dynamic"
-
Scripts:
Stack - Use same stack script as rocket stack
Card - Use side scroller card script
-
Start and Stop buttons - copy/paste from rocket stack
-
Add audio loop as desired.
-
Test in simulator or on device.
See the stacks "sideScroller1.livecode" and "sideScrollerFinal.livecode" on the server to see the final product.
Back
BYU LiveCode Lessons Gateway
Maintained by
Devin Asay.
Copyright © 2005 Brigham Young University.
This page last updated on March 27, 2019 16:53:29.