Background
5 Rename Layout and Event Sheet
5 Rename Layout and Event Sheet
6 Rename Layer 0 to Background
6 Rename Layer 0 to Background
7 Add a Sprite, call it Background
7 Add a Sprite, call it Background
8 Load all frames from Assets - Background Folder (Ctrl A to select all)
8 Load all frames from Assets - Background Folder (Ctrl A to select all)
9 Select your Layout in Project View (RIGHT)
9 Select your Layout in Project View (RIGHT)
10 Adjust settings on LEFT
10 Adjust settings on LEFT
Enable Show Grid
Enable Show Grid
Enable Snapping
Enable Snapping
Adjust Grid Size
Adjust Grid Size
11 Change the origin of the background tile to TOP LEFT
11 Change the origin of the background tile to TOP LEFT
Apply to the WHOLE ANIMATION (right click origin)
Apply to the WHOLE ANIMATION (right click origin)
Set Animation SPEED to 0
Set Animation SPEED to 0
12 Select Background in Project view
12 Select Background in Project view
Set the initial frame to the animation number you want your background colour to be ( eg 0 for grey, 1 for brown etc)
Set the initial frame to the animation number you want your background colour to be ( eg 0 for grey, 1 for brown etc)
13 Snap first Background block to position 0,0
13 Snap first Background block to position 0,0
14 Duplicate 15 squares across (Select sprite, Hold Ctrl, left click, drag and release)
14 Duplicate 15 squares across (Select sprite, Hold Ctrl, left click, drag and release)
15 Create 9 rows
15 Create 9 rows
16 Select your background:
16 Select your background:
17 Add two instance variables and name them StartX and StartY
17 Add two instance variables and name them StartX and StartY
18 Add a new Event Sheet, name it Background
18 Add a new Event Sheet, name it Background
19 Code the Background Event Sheet
19 Code the Background Event Sheet
Note that the last event in this code snippet is found in SYSTEM --> COMPARE X
Note that the last event in this code snippet is found in SYSTEM --> COMPARE X
Code discussion
Code discussion
Record starting x and y position of each block.
Record starting x and y position of each block.
Every 0.050 seconds:
Every 0.050 seconds:
Move each block diagonally up and left.
Move each block diagonally up and left.
Once block moved 64 pixels left
Once block moved 64 pixels left
(the width of a block)
(the width of a block)
Move it back to it's original position.
Move it back to it's original position.
20 Include the Background Event Sheet in Level 1 Event Sheet (Right click in Level 1 event sheet, include Background event sheet)
20 Include the Background Event Sheet in Level 1 Event Sheet (Right click in Level 1 event sheet, include Background event sheet)
Game Development Theory - Modular Code for Re-use
Game Development Theory - Modular Code for Re-use
Now we have encapsulated the data for the background.
Now we have encapsulated the data for the background.
We can include the background event sheet in any level.
We can include the background event sheet in any level.
We can change the initial frame to have a different background.
We can change the initial frame to have a different background.
21 Lock the background layer so that we do not move it by accident.
21 Lock the background layer so that we do not move it by accident.