Skip to content

Commit 57c695c

Browse files
committed
Updated basic message passing example
1 parent a438501 commit 57c695c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+30
-220
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-1.35 KB
Binary file not shown.
-2.74 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-699 Bytes
Binary file not shown.
Binary file not shown.
-57.2 KB
Binary file not shown.
-97.5 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-89.6 KB
Binary file not shown.
Binary file not shown.
-402 Bytes
Binary file not shown.
-4.01 KB
Binary file not shown.
Binary file not shown.
+3-83
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,13 @@
1-
images {
2-
image: "/assets/images/spinner.png"
3-
}
4-
images {
5-
image: "/assets/images/elementStone019.png"
6-
}
7-
images {
8-
image: "/assets/images/elementStone023.png"
9-
}
10-
images {
11-
image: "/assets/images/bunny1_ready.png"
12-
}
13-
images {
14-
image: "/assets/images/bunny2_ready.png"
15-
}
16-
images {
17-
image: "/assets/images/carrot.png"
18-
}
19-
images {
20-
image: "/assets/images/red_button12.png"
21-
}
22-
images {
23-
image: "/assets/images/flame.png"
24-
}
25-
images {
26-
image: "/assets/images/smoke.png"
27-
}
28-
images {
29-
image: "/assets/images/rainbow.png"
30-
}
31-
images {
32-
image: "/assets/images/enemyFloating_1.png"
33-
}
34-
images {
35-
image: "/assets/images/logo-color.png"
36-
}
371
images {
382
image: "/assets/images/shipGreen_manned.png"
393
}
404
images {
41-
image: "/assets/images/elementMetal001.png"
42-
}
43-
images {
44-
image: "/assets/images/plank_slice.png"
45-
}
46-
images {
47-
image: "/assets/images/hitman1_machine.png"
48-
}
49-
images {
50-
image: "/assets/images/green_button03.png"
51-
}
52-
images {
53-
image: "/assets/images/playerShip1_red.png"
54-
}
55-
images {
56-
image: "/assets/images/enemyBlack1.png"
57-
}
58-
images {
59-
image: "/assets/images/lighting_blue.png"
5+
image: "/assets/images/shipBeige_manned.png"
606
}
617
images {
62-
image: "/assets/images/particle_brown.png"
8+
image: "/assets/images/shipBlue_manned.png"
639
}
6410
images {
65-
image: "/assets/images/crosshair010.png"
66-
}
67-
images {
68-
image: "/assets/images/bar_round_large_grey.png"
69-
}
70-
images {
71-
image: "/assets/images/bar_round_large_red.png"
72-
}
73-
animations {
74-
id: "coin"
75-
images {
76-
image: "/assets/images/coin/dcoin_1.png"
77-
}
78-
images {
79-
image: "/assets/images/coin/dcoin_2.png"
80-
}
81-
images {
82-
image: "/assets/images/coin/dcoin_3.png"
83-
}
84-
images {
85-
image: "/assets/images/coin/dcoin_4.png"
86-
}
87-
images {
88-
image: "/assets/images/coin/dcoin_5.png"
89-
}
90-
playback: PLAYBACK_LOOP_FORWARD
91-
fps: 8
11+
image: "/assets/images/shipPink_manned.png"
9212
}
9313
extrude_borders: 2

basics/message_passing/example.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,220 +1,110 @@
11
name: "default"
22
scale_along_z: 0
33
embedded_instances {
4-
id: "bunny 1"
4+
id: "spaceship1"
55
data: "components {\n"
66
" id: \"script\"\n"
7-
" component: \"/example/bunny1.script\"\n"
8-
" position {\n"
9-
" x: 0.0\n"
10-
" y: 0.0\n"
11-
" z: 0.0\n"
12-
" }\n"
13-
" rotation {\n"
14-
" x: 0.0\n"
15-
" y: 0.0\n"
16-
" z: 0.0\n"
17-
" w: 1.0\n"
18-
" }\n"
7+
" component: \"/example/spaceship1.script\"\n"
198
"}\n"
209
"embedded_components {\n"
2110
" id: \"sprite\"\n"
2211
" type: \"sprite\"\n"
23-
" data: \"tile_set: \\\"/assets/sprites.atlas\\\"\\n"
24-
"default_animation: \\\"bunny1_ready\\\"\\n"
12+
" data: \"default_animation: \\\"shipBlue_manned\\\"\\n"
2513
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
26-
"blend_mode: BLEND_MODE_ALPHA\\n"
14+
"textures {\\n"
15+
" sampler: \\\"texture_sampler\\\"\\n"
16+
" texture: \\\"/assets/sprites.atlas\\\"\\n"
17+
"}\\n"
2718
"\"\n"
28-
" position {\n"
29-
" x: 0.0\n"
30-
" y: 0.0\n"
31-
" z: 0.0\n"
32-
" }\n"
33-
" rotation {\n"
34-
" x: 0.0\n"
35-
" y: 0.0\n"
36-
" z: 0.0\n"
37-
" w: 1.0\n"
38-
" }\n"
3919
"}\n"
4020
"embedded_components {\n"
4121
" id: \"speech\"\n"
4222
" type: \"label\"\n"
4323
" data: \"size {\\n"
4424
" x: 128.0\\n"
4525
" y: 32.0\\n"
46-
" z: 0.0\\n"
47-
" w: 0.0\\n"
48-
"}\\n"
49-
"scale {\\n"
50-
" x: 0.5\\n"
51-
" y: 0.5\\n"
52-
" z: 1.0\\n"
53-
" w: 0.0\\n"
5426
"}\\n"
5527
"color {\\n"
5628
" x: 0.0\\n"
5729
" y: 0.5647059\\n"
5830
" z: 0.99215686\\n"
59-
" w: 1.0\\n"
6031
"}\\n"
6132
"outline {\\n"
6233
" x: 1.0\\n"
6334
" y: 1.0\\n"
6435
" z: 1.0\\n"
65-
" w: 1.0\\n"
66-
"}\\n"
67-
"shadow {\\n"
68-
" x: 0.0\\n"
69-
" y: 0.0\\n"
70-
" z: 0.0\\n"
71-
" w: 1.0\\n"
7236
"}\\n"
73-
"leading: 1.0\\n"
74-
"tracking: 0.0\\n"
7537
"pivot: PIVOT_W\\n"
76-
"blend_mode: BLEND_MODE_ALPHA\\n"
77-
"line_break: false\\n"
7838
"text: \\\"...\\\"\\n"
7939
"font: \\\"/assets/text48.font\\\"\\n"
8040
"material: \\\"/builtins/fonts/label.material\\\"\\n"
8141
"\"\n"
8242
" position {\n"
8343
" x: 54.068\n"
8444
" y: 61.483\n"
85-
" z: 0.0\n"
8645
" }\n"
87-
" rotation {\n"
88-
" x: 0.0\n"
89-
" y: 0.0\n"
90-
" z: 0.0\n"
91-
" w: 1.0\n"
46+
" scale {\n"
47+
" x: 0.5\n"
48+
" y: 0.5\n"
9249
" }\n"
9350
"}\n"
9451
""
9552
position {
9653
x: 543.188
9754
y: 210.168
98-
z: 0.0
99-
}
100-
rotation {
101-
x: 0.0
102-
y: 0.0
103-
z: 0.0
104-
w: 1.0
105-
}
106-
scale3 {
107-
x: 1.0
108-
y: 1.0
109-
z: 1.0
11055
}
11156
}
11257
embedded_instances {
113-
id: "bunny 2"
58+
id: "spaceship2"
11459
data: "components {\n"
11560
" id: \"script\"\n"
116-
" component: \"/example/bunny2.script\"\n"
117-
" position {\n"
118-
" x: 0.0\n"
119-
" y: 0.0\n"
120-
" z: 0.0\n"
121-
" }\n"
122-
" rotation {\n"
123-
" x: 0.0\n"
124-
" y: 0.0\n"
125-
" z: 0.0\n"
126-
" w: 1.0\n"
127-
" }\n"
61+
" component: \"/example/spaceship2.script\"\n"
12862
"}\n"
12963
"embedded_components {\n"
13064
" id: \"sprite\"\n"
13165
" type: \"sprite\"\n"
132-
" data: \"tile_set: \\\"/assets/sprites.atlas\\\"\\n"
133-
"default_animation: \\\"bunny2_ready\\\"\\n"
66+
" data: \"default_animation: \\\"shipPink_manned\\\"\\n"
13467
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
135-
"blend_mode: BLEND_MODE_ALPHA\\n"
68+
"textures {\\n"
69+
" sampler: \\\"texture_sampler\\\"\\n"
70+
" texture: \\\"/assets/sprites.atlas\\\"\\n"
71+
"}\\n"
13672
"\"\n"
137-
" position {\n"
138-
" x: 0.0\n"
139-
" y: 0.0\n"
140-
" z: 0.0\n"
141-
" }\n"
142-
" rotation {\n"
143-
" x: 0.0\n"
144-
" y: 0.0\n"
145-
" z: 0.0\n"
146-
" w: 1.0\n"
147-
" }\n"
14873
"}\n"
14974
"embedded_components {\n"
15075
" id: \"speech\"\n"
15176
" type: \"label\"\n"
15277
" data: \"size {\\n"
15378
" x: 128.0\\n"
15479
" y: 32.0\\n"
155-
" z: 0.0\\n"
156-
" w: 0.0\\n"
157-
"}\\n"
158-
"scale {\\n"
159-
" x: 0.5\\n"
160-
" y: 0.5\\n"
161-
" z: 1.0\\n"
162-
" w: 0.0\\n"
16380
"}\\n"
16481
"color {\\n"
16582
" x: 0.0\\n"
16683
" y: 0.5647059\\n"
16784
" z: 0.99215686\\n"
168-
" w: 1.0\\n"
16985
"}\\n"
17086
"outline {\\n"
17187
" x: 1.0\\n"
17288
" y: 1.0\\n"
17389
" z: 1.0\\n"
174-
" w: 1.0\\n"
175-
"}\\n"
176-
"shadow {\\n"
177-
" x: 0.0\\n"
178-
" y: 0.0\\n"
179-
" z: 0.0\\n"
180-
" w: 1.0\\n"
18190
"}\\n"
182-
"leading: 1.0\\n"
183-
"tracking: 0.0\\n"
18491
"pivot: PIVOT_W\\n"
185-
"blend_mode: BLEND_MODE_ALPHA\\n"
186-
"line_break: false\\n"
18792
"text: \\\"Click and I will follow...\\\"\\n"
18893
"font: \\\"/assets/text48.font\\\"\\n"
18994
"material: \\\"/builtins/fonts/label.material\\\"\\n"
19095
"\"\n"
19196
" position {\n"
19297
" x: 46.972\n"
19398
" y: 66.551\n"
194-
" z: 0.0\n"
19599
" }\n"
196-
" rotation {\n"
197-
" x: 0.0\n"
198-
" y: 0.0\n"
199-
" z: 0.0\n"
200-
" w: 1.0\n"
100+
" scale {\n"
101+
" x: 0.5\n"
102+
" y: 0.5\n"
201103
" }\n"
202104
"}\n"
203105
""
204106
position {
205107
x: 245.774
206108
y: 532.971
207-
z: 0.0
208-
}
209-
rotation {
210-
x: 0.0
211-
y: 0.0
212-
z: 0.0
213-
w: 1.0
214-
}
215-
scale3 {
216-
x: 1.0
217-
y: 1.0
218-
z: 1.0
219109
}
220110
}

basics/message_passing/example/bunny1.script renamed to basics/message_passing/example/spaceship1.script

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local function landed(self) -- <2>
22
label.set_text("#speech", "I'm there!")
3-
msg.post("bunny 2#script", "i'm there")
3+
msg.post("spaceship2#script", "i'm there")
44
end
55

66
function on_message(self, message_id, message, sender)
@@ -14,5 +14,5 @@ end
1414
1. If someone sends us a "go to" message, set the speech label text and animate to the position supplied
1515
in the message data. At the end of animation, call the function `landed()`
1616
2. This function is called when the position animation is completed. It sets the speech label text and then
17-
sends a message called "i'm there" to the component "script" in the "bunny 2" game object.
17+
sends a message called "i'm there" to the component "script" in the "spaceship2" game object.
1818
--]]

basics/message_passing/example/bunny2.script renamed to basics/message_passing/example/spaceship2.script

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ local function landed(self) -- <6>
1010
local opposite = vmath.vector3()
1111
opposite.x = 720 - pos.x
1212
opposite.y = 720 - pos.y
13-
msg.post("bunny 1#script", "go to", { position = opposite })
13+
msg.post("spaceship1#script", "go to", { position = opposite })
1414
end
1515

1616
function on_message(self, message_id, message, sender)
@@ -32,15 +32,15 @@ end
3232

3333
--[[
3434
1. Tell the engine that we want to receive input.
35-
2. Store a flag in the current script component instance that tells us if the bunny is moving or not.
36-
3. If user clicked and the bunny is not moving.
35+
2. Store a flag in the current script component instance that tells us if the spaceship is moving or not.
36+
3. If user clicked and the spaceship is not moving.
3737
4. Send a message to this script component ("#" is shorthand for that) saying "go to" and the clicked position
3838
as part of the message data.
3939
5. If a "go to" message is received, set the speech label text and then animate the position of the current
4040
game object ("." is shorthand for that) to the position send in the message data. When the animation is
4141
done the function `landed()` is called.
4242
6. When `landed()` is called on animation complete, set the label text, then calculate a position on the
4343
opposite of the screen and send a message called "go to" to the component "script" in the game object
44-
"bunny 1". Supplied with the message is the opposite position as message data.
44+
"spaceship11". Supplied with the message is the opposite position as message data.
4545
7. If someone sends us a message called "i'm there" we react by just changing the speech label text.
4646
--]]

0 commit comments

Comments
 (0)