Skip to content

Commit 4c8f047

Browse files
committed
Merge branch 'master' into update-1.7.0
2 parents 1edb7d8 + d2e85df commit 4c8f047

File tree

7 files changed

+535
-3
lines changed

7 files changed

+535
-3
lines changed

examples/_main/loader.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,9 +1109,9 @@ embedded_components {
11091109
}
11101110
}
11111111
embedded_components {
1112-
id: "material/vertexcolor"
1112+
id: "collection/timestep"
11131113
type: "collectionproxy"
1114-
data: "collection: \"/examples/material/vertexcolor/vertexcolor.collection\"\n"
1114+
data: "collection: \"/examples/collection/timestep/timestep.collection\"\n"
11151115
"exclude: false\n"
11161116
""
11171117
position {
@@ -1126,3 +1126,21 @@ embedded_components {
11261126
w: 1.0
11271127
}
11281128
}
1129+
embedded_components {
1130+
id: "material/vertexcolor"
1131+
type: "collectionproxy"
1132+
data: "collection: \"/examples/material/vertexcolor/vertexcolor.collection\"\n"
1133+
"exclude: false\n"
1134+
""
1135+
position {
1136+
x: 0.0
1137+
y: 0.0
1138+
z: 0.0
1139+
}
1140+
rotation {
1141+
x: 0.0
1142+
y: 0.0
1143+
z: 0.0
1144+
w: 1.0
1145+
}
1146+
}

examples/_main/menu.gui_script

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function init(self)
112112
self.index["sound"] = { "music", "fade_in_out", "panning" }
113113
self.index["render"] = { "camera", "screen_to_world" }
114114
self.index["debug"] = { "physics", "profile" }
115-
self.index["collection"] = { "proxy", "splash" }
115+
self.index["collection"] = { "proxy", "splash", "timestep" }
116116
self.index["sprite"] = { "size", "tint", "flip", "bunnymark" }
117117
self.index["file"] = { "sys_save_load" }
118118
self.index["tilemap"] = { "collisions", "get_set_tile" }
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
-- speed of the time in the collection proxy
2+
go.property("speed", 1)
3+
4+
function init(self)
5+
-- acquire input for this script
6+
msg.post(".", "acquire_input_focus")
7+
-- load the collection proxy
8+
msg.post("#gameproxy", "async_load")
9+
end
10+
11+
function update(self, dt)
12+
-- update the time step of the proxy each frame since it might be animated
13+
msg.post("#gameproxy", "set_time_step", { factor = self.speed, mode = 0 })
14+
label.set_text("#label", tostring(self.speed))
15+
end
16+
17+
function on_message(self, message_id, message, sender)
18+
if message_id == hash("proxy_loaded") then
19+
msg.post(sender, "enable")
20+
elseif message_id == hash("animate_speed") then
21+
-- cancel any current animation of the speed property
22+
go.cancel_animations("#", "speed")
23+
-- start animation of the speed property
24+
local to = message.to
25+
local change = math.abs(self.speed - to)
26+
local rate_of_change = 2
27+
local duration = change / rate_of_change
28+
go.animate("#", "speed", go.PLAYBACK_ONCE_FORWARD, to, go.EASING_LINEAR, duration)
29+
elseif message_id == hash("change_speed") then
30+
-- cancel any current animation of the speed property
31+
go.cancel_animations("#", "speed")
32+
-- make sure speed never goes below 0
33+
self.speed = math.max(self.speed + message.amount, 0)
34+
end
35+
end
Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
name: "game"
2+
scale_along_z: 0
3+
embedded_instances {
4+
id: "game"
5+
data: "components {\n"
6+
" id: \"game\"\n"
7+
" component: \"/examples/collection/timestep/game.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"
19+
" property_decls {\n"
20+
" }\n"
21+
"}\n"
22+
""
23+
position {
24+
x: 0.0
25+
y: 0.0
26+
z: 0.0
27+
}
28+
rotation {
29+
x: 0.0
30+
y: 0.0
31+
z: 0.0
32+
w: 1.0
33+
}
34+
scale3 {
35+
x: 1.0
36+
y: 1.0
37+
z: 1.0
38+
}
39+
}
40+
embedded_instances {
41+
id: "enemy1"
42+
data: "embedded_components {\n"
43+
" id: \"sprite\"\n"
44+
" type: \"sprite\"\n"
45+
" data: \"default_animation: \\\"enemyBlack1\\\"\\n"
46+
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
47+
"blend_mode: BLEND_MODE_ALPHA\\n"
48+
"textures {\\n"
49+
" sampler: \\\"texture_sampler\\\"\\n"
50+
" texture: \\\"/assets/sprites.atlas\\\"\\n"
51+
"}\\n"
52+
"\"\n"
53+
" position {\n"
54+
" x: 0.0\n"
55+
" y: 0.0\n"
56+
" z: 0.0\n"
57+
" }\n"
58+
" rotation {\n"
59+
" x: 0.0\n"
60+
" y: 0.0\n"
61+
" z: 0.0\n"
62+
" w: 1.0\n"
63+
" }\n"
64+
"}\n"
65+
""
66+
position {
67+
x: 0.0
68+
y: 589.0
69+
z: 0.0
70+
}
71+
rotation {
72+
x: 0.0
73+
y: 0.0
74+
z: 0.0
75+
w: 1.0
76+
}
77+
scale3 {
78+
x: 1.0
79+
y: 1.0
80+
z: 1.0
81+
}
82+
}
83+
embedded_instances {
84+
id: "player"
85+
data: "embedded_components {\n"
86+
" id: \"sprite\"\n"
87+
" type: \"sprite\"\n"
88+
" data: \"default_animation: \\\"playerShip1_red\\\"\\n"
89+
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
90+
"blend_mode: BLEND_MODE_ALPHA\\n"
91+
"textures {\\n"
92+
" sampler: \\\"texture_sampler\\\"\\n"
93+
" texture: \\\"/assets/sprites.atlas\\\"\\n"
94+
"}\\n"
95+
"\"\n"
96+
" position {\n"
97+
" x: 0.0\n"
98+
" y: 0.0\n"
99+
" z: 0.0\n"
100+
" }\n"
101+
" rotation {\n"
102+
" x: 0.0\n"
103+
" y: 0.0\n"
104+
" z: 0.0\n"
105+
" w: 1.0\n"
106+
" }\n"
107+
"}\n"
108+
""
109+
position {
110+
x: 360.0
111+
y: 100.0
112+
z: 0.0
113+
}
114+
rotation {
115+
x: 0.0
116+
y: 0.0
117+
z: 0.0
118+
w: 1.0
119+
}
120+
scale3 {
121+
x: 1.0
122+
y: 1.0
123+
z: 1.0
124+
}
125+
}
126+
embedded_instances {
127+
id: "enemy2"
128+
data: "embedded_components {\n"
129+
" id: \"sprite\"\n"
130+
" type: \"sprite\"\n"
131+
" data: \"default_animation: \\\"enemyBlack1\\\"\\n"
132+
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
133+
"blend_mode: BLEND_MODE_ALPHA\\n"
134+
"textures {\\n"
135+
" sampler: \\\"texture_sampler\\\"\\n"
136+
" texture: \\\"/assets/sprites.atlas\\\"\\n"
137+
"}\\n"
138+
"\"\n"
139+
" position {\n"
140+
" x: 0.0\n"
141+
" y: 0.0\n"
142+
" z: 0.0\n"
143+
" }\n"
144+
" rotation {\n"
145+
" x: 0.0\n"
146+
" y: 0.0\n"
147+
" z: 0.0\n"
148+
" w: 1.0\n"
149+
" }\n"
150+
"}\n"
151+
""
152+
position {
153+
x: 0.0
154+
y: 494.0
155+
z: 0.0
156+
}
157+
rotation {
158+
x: 0.0
159+
y: 0.0
160+
z: 0.0
161+
w: 1.0
162+
}
163+
scale3 {
164+
x: 1.0
165+
y: 1.0
166+
z: 1.0
167+
}
168+
}
169+
embedded_instances {
170+
id: "enemy3"
171+
data: "embedded_components {\n"
172+
" id: \"sprite\"\n"
173+
" type: \"sprite\"\n"
174+
" data: \"default_animation: \\\"enemyBlack1\\\"\\n"
175+
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
176+
"blend_mode: BLEND_MODE_ALPHA\\n"
177+
"textures {\\n"
178+
" sampler: \\\"texture_sampler\\\"\\n"
179+
" texture: \\\"/assets/sprites.atlas\\\"\\n"
180+
"}\\n"
181+
"\"\n"
182+
" position {\n"
183+
" x: 0.0\n"
184+
" y: 0.0\n"
185+
" z: 0.0\n"
186+
" }\n"
187+
" rotation {\n"
188+
" x: 0.0\n"
189+
" y: 0.0\n"
190+
" z: 0.0\n"
191+
" w: 1.0\n"
192+
" }\n"
193+
"}\n"
194+
""
195+
position {
196+
x: 0.0
197+
y: 397.0
198+
z: 0.0
199+
}
200+
rotation {
201+
x: 0.0
202+
y: 0.0
203+
z: 0.0
204+
w: 1.0
205+
}
206+
scale3 {
207+
x: 1.0
208+
y: 1.0
209+
z: 1.0
210+
}
211+
}
212+
embedded_instances {
213+
id: "enemy4"
214+
data: "embedded_components {\n"
215+
" id: \"sprite\"\n"
216+
" type: \"sprite\"\n"
217+
" data: \"default_animation: \\\"enemyBlack1\\\"\\n"
218+
"material: \\\"/builtins/materials/sprite.material\\\"\\n"
219+
"blend_mode: BLEND_MODE_ALPHA\\n"
220+
"textures {\\n"
221+
" sampler: \\\"texture_sampler\\\"\\n"
222+
" texture: \\\"/assets/sprites.atlas\\\"\\n"
223+
"}\\n"
224+
"\"\n"
225+
" position {\n"
226+
" x: 0.0\n"
227+
" y: 0.0\n"
228+
" z: 0.0\n"
229+
" }\n"
230+
" rotation {\n"
231+
" x: 0.0\n"
232+
" y: 0.0\n"
233+
" z: 0.0\n"
234+
" w: 1.0\n"
235+
" }\n"
236+
"}\n"
237+
""
238+
position {
239+
x: 0.0
240+
y: 294.0
241+
z: 0.0
242+
}
243+
rotation {
244+
x: 0.0
245+
y: 0.0
246+
z: 0.0
247+
w: 1.0
248+
}
249+
scale3 {
250+
x: 1.0
251+
y: 1.0
252+
z: 1.0
253+
}
254+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function init(self)
2+
-- get input to this script
3+
msg.post(".", "acquire_input_focus")
4+
5+
-- animate some game objects
6+
go.animate("enemy1", "position.x", go.PLAYBACK_LOOP_PINGPONG, 720, go.EASING_INOUTQUAD, 5, 0)
7+
go.animate("enemy2", "position.x", go.PLAYBACK_LOOP_PINGPONG, 720, go.EASING_INOUTQUAD, 5, 0.5)
8+
go.animate("enemy3", "position.x", go.PLAYBACK_LOOP_PINGPONG, 720, go.EASING_INOUTQUAD, 5, 1)
9+
go.animate("enemy4", "position.x", go.PLAYBACK_LOOP_PINGPONG, 720, go.EASING_INOUTQUAD, 5, 1.5)
10+
end
11+
12+
function on_input(self, action_id, action)
13+
if action_id == hash("left") then
14+
msg.post("timestep:/controller", "change_speed", { amount = -0.01 })
15+
elseif action_id == hash("right") then
16+
msg.post("timestep:/controller", "change_speed", { amount = 0.01 })
17+
elseif action_id == hash("action") and action.pressed then
18+
-- flip self.to between 0 and 3 each time
19+
self.to = 3 - (self.to or 0)
20+
msg.post("timestep:/controller", "animate_speed", { to = self.to })
21+
end
22+
end

0 commit comments

Comments
 (0)