Game Development Reference
In-Depth Information
Creating a Cloud Object:
1.
Create a new object called
obj_clouds
, (
Misc
group) give it the
spr_clouds
sprite, and
set its
Depth
to
10000
(behind everything).
2.
Add a
Draw
event. Next, we're going to create some variables that aren't strictly
necessary, but will aid in your understanding. The first four of these provide the left,
right, top, and bottom boundaries of the view in the room.
Include a
Set Variable
action (
control
tab) that sets
view_left
to
view_xview[0]
. The
variable
view_xview[0]
holds the x position of
view0
in the room. This is the left
boundary of the view area the clouds need to cover.
3.
Include a
Set Variable
action that sets
view_right
to
view_left+view_wview[0]
. The
variable
view_wview[0]
holds the width of
view0
. By adding the width, we get the right
boundary of the view area.
4.
Include a
Set Variable
action that sets
view_top
to
view_yview[0]
. Yes, the variable
view_yview[0]
holds the y position of
view0
in the room, making it the top boundary of
the view area.
5.
Figure 6-8.
The clouds will actually only be drawn behind the view area that the player can see and not
behind the rest of the room
Include a
Set Variable
action that sets
view_bottom
to
view_top+view_hview[0]
. By
adding the height of the view, we get the bottom boundary of the view area.
6.
7.
Include a
Set Variable
action that sets
x
to
view_left
. This makes the cloud object's
horizontal position follow the view's horizontal position.
Search WWH ::
Custom Search