Vertical scrolling with a fixed 3x canvas

1,005 views
Skip to first unread message

Scott Ferguson

unread,
Mar 9, 2016, 6:03:01 AM3/9/16
to app-inventor-de...@googlegroups.com
This project has a helicopter rising through a canyon.

Screen1.VerticalAlignment is set to 'center' to allow vertical scrolling to work.
GameCanvas.Height is set to 3x Screen1.Height.
Inside GameCanvas are two scrolling ImageSprites -- Midground and Foreground and a fixed Helicopter ImageSprite.
Midground and Foreground are sized to 2x Screen1.Height which allows them to move down the height of the screen before being reset to their starting positions.
Midground contains the most distant canyon walls image and moves downward at ScrollingSpeed rate.
Foreground contains the nearest canyon walls image and moves downward at 2x ScrollingSpeed rate.

The ScrollCanyonWalls procedure uses the Math 'modulo of' block to move each scrolling ImageSprite downward.
When either ImageSprite has scrolled Screen1.Height distance, it is moved back to the top of the Canvas and continues to move down again.
This is not noticeable to the user.
It appears that the sprites are continuing to scroll down as the top and bottom of the sprites are identical.

The FlyHelicopter procedure switches between two images for the Helicopter animation.

---
VerticalScrollingFixed3xCanvas.aia
blocks.PNG
Screenshot_2016-03-09-04-54-27.png
Foreground.png
Midground.png
Background.png
heli1.png
heli2.png
heli.ogg

Iftak Hussain

unread,
May 16, 2017, 7:55:19 AM5/16/17
to App Inventor Developers Library
Sir this is very much helpful. This may help me a lot ..
Reply all
Reply to author
Forward
0 new messages