-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into update-1.7.0
- Loading branch information
Showing
7 changed files
with
535 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-- speed of the time in the collection proxy | ||
go.property("speed", 1) | ||
|
||
function init(self) | ||
-- acquire input for this script | ||
msg.post(".", "acquire_input_focus") | ||
-- load the collection proxy | ||
msg.post("#gameproxy", "async_load") | ||
end | ||
|
||
function update(self, dt) | ||
-- update the time step of the proxy each frame since it might be animated | ||
msg.post("#gameproxy", "set_time_step", { factor = self.speed, mode = 0 }) | ||
label.set_text("#label", tostring(self.speed)) | ||
end | ||
|
||
function on_message(self, message_id, message, sender) | ||
if message_id == hash("proxy_loaded") then | ||
msg.post(sender, "enable") | ||
elseif message_id == hash("animate_speed") then | ||
-- cancel any current animation of the speed property | ||
go.cancel_animations("#", "speed") | ||
-- start animation of the speed property | ||
local to = message.to | ||
local change = math.abs(self.speed - to) | ||
local rate_of_change = 2 | ||
local duration = change / rate_of_change | ||
go.animate("#", "speed", go.PLAYBACK_ONCE_FORWARD, to, go.EASING_LINEAR, duration) | ||
elseif message_id == hash("change_speed") then | ||
-- cancel any current animation of the speed property | ||
go.cancel_animations("#", "speed") | ||
-- make sure speed never goes below 0 | ||
self.speed = math.max(self.speed + message.amount, 0) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,254 @@ | ||
name: "game" | ||
scale_along_z: 0 | ||
embedded_instances { | ||
id: "game" | ||
data: "components {\n" | ||
" id: \"game\"\n" | ||
" component: \"/examples/collection/timestep/game.script\"\n" | ||
" position {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" }\n" | ||
" rotation {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" w: 1.0\n" | ||
" }\n" | ||
" property_decls {\n" | ||
" }\n" | ||
"}\n" | ||
"" | ||
position { | ||
x: 0.0 | ||
y: 0.0 | ||
z: 0.0 | ||
} | ||
rotation { | ||
x: 0.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 1.0 | ||
} | ||
scale3 { | ||
x: 1.0 | ||
y: 1.0 | ||
z: 1.0 | ||
} | ||
} | ||
embedded_instances { | ||
id: "enemy1" | ||
data: "embedded_components {\n" | ||
" id: \"sprite\"\n" | ||
" type: \"sprite\"\n" | ||
" data: \"default_animation: \\\"enemyBlack1\\\"\\n" | ||
"material: \\\"/builtins/materials/sprite.material\\\"\\n" | ||
"blend_mode: BLEND_MODE_ALPHA\\n" | ||
"textures {\\n" | ||
" sampler: \\\"texture_sampler\\\"\\n" | ||
" texture: \\\"/assets/sprites.atlas\\\"\\n" | ||
"}\\n" | ||
"\"\n" | ||
" position {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" }\n" | ||
" rotation {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" w: 1.0\n" | ||
" }\n" | ||
"}\n" | ||
"" | ||
position { | ||
x: 0.0 | ||
y: 589.0 | ||
z: 0.0 | ||
} | ||
rotation { | ||
x: 0.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 1.0 | ||
} | ||
scale3 { | ||
x: 1.0 | ||
y: 1.0 | ||
z: 1.0 | ||
} | ||
} | ||
embedded_instances { | ||
id: "player" | ||
data: "embedded_components {\n" | ||
" id: \"sprite\"\n" | ||
" type: \"sprite\"\n" | ||
" data: \"default_animation: \\\"playerShip1_red\\\"\\n" | ||
"material: \\\"/builtins/materials/sprite.material\\\"\\n" | ||
"blend_mode: BLEND_MODE_ALPHA\\n" | ||
"textures {\\n" | ||
" sampler: \\\"texture_sampler\\\"\\n" | ||
" texture: \\\"/assets/sprites.atlas\\\"\\n" | ||
"}\\n" | ||
"\"\n" | ||
" position {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" }\n" | ||
" rotation {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" w: 1.0\n" | ||
" }\n" | ||
"}\n" | ||
"" | ||
position { | ||
x: 360.0 | ||
y: 100.0 | ||
z: 0.0 | ||
} | ||
rotation { | ||
x: 0.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 1.0 | ||
} | ||
scale3 { | ||
x: 1.0 | ||
y: 1.0 | ||
z: 1.0 | ||
} | ||
} | ||
embedded_instances { | ||
id: "enemy2" | ||
data: "embedded_components {\n" | ||
" id: \"sprite\"\n" | ||
" type: \"sprite\"\n" | ||
" data: \"default_animation: \\\"enemyBlack1\\\"\\n" | ||
"material: \\\"/builtins/materials/sprite.material\\\"\\n" | ||
"blend_mode: BLEND_MODE_ALPHA\\n" | ||
"textures {\\n" | ||
" sampler: \\\"texture_sampler\\\"\\n" | ||
" texture: \\\"/assets/sprites.atlas\\\"\\n" | ||
"}\\n" | ||
"\"\n" | ||
" position {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" }\n" | ||
" rotation {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" w: 1.0\n" | ||
" }\n" | ||
"}\n" | ||
"" | ||
position { | ||
x: 0.0 | ||
y: 494.0 | ||
z: 0.0 | ||
} | ||
rotation { | ||
x: 0.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 1.0 | ||
} | ||
scale3 { | ||
x: 1.0 | ||
y: 1.0 | ||
z: 1.0 | ||
} | ||
} | ||
embedded_instances { | ||
id: "enemy3" | ||
data: "embedded_components {\n" | ||
" id: \"sprite\"\n" | ||
" type: \"sprite\"\n" | ||
" data: \"default_animation: \\\"enemyBlack1\\\"\\n" | ||
"material: \\\"/builtins/materials/sprite.material\\\"\\n" | ||
"blend_mode: BLEND_MODE_ALPHA\\n" | ||
"textures {\\n" | ||
" sampler: \\\"texture_sampler\\\"\\n" | ||
" texture: \\\"/assets/sprites.atlas\\\"\\n" | ||
"}\\n" | ||
"\"\n" | ||
" position {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" }\n" | ||
" rotation {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" w: 1.0\n" | ||
" }\n" | ||
"}\n" | ||
"" | ||
position { | ||
x: 0.0 | ||
y: 397.0 | ||
z: 0.0 | ||
} | ||
rotation { | ||
x: 0.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 1.0 | ||
} | ||
scale3 { | ||
x: 1.0 | ||
y: 1.0 | ||
z: 1.0 | ||
} | ||
} | ||
embedded_instances { | ||
id: "enemy4" | ||
data: "embedded_components {\n" | ||
" id: \"sprite\"\n" | ||
" type: \"sprite\"\n" | ||
" data: \"default_animation: \\\"enemyBlack1\\\"\\n" | ||
"material: \\\"/builtins/materials/sprite.material\\\"\\n" | ||
"blend_mode: BLEND_MODE_ALPHA\\n" | ||
"textures {\\n" | ||
" sampler: \\\"texture_sampler\\\"\\n" | ||
" texture: \\\"/assets/sprites.atlas\\\"\\n" | ||
"}\\n" | ||
"\"\n" | ||
" position {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" }\n" | ||
" rotation {\n" | ||
" x: 0.0\n" | ||
" y: 0.0\n" | ||
" z: 0.0\n" | ||
" w: 1.0\n" | ||
" }\n" | ||
"}\n" | ||
"" | ||
position { | ||
x: 0.0 | ||
y: 294.0 | ||
z: 0.0 | ||
} | ||
rotation { | ||
x: 0.0 | ||
y: 0.0 | ||
z: 0.0 | ||
w: 1.0 | ||
} | ||
scale3 { | ||
x: 1.0 | ||
y: 1.0 | ||
z: 1.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function init(self) | ||
-- get input to this script | ||
msg.post(".", "acquire_input_focus") | ||
|
||
-- animate some game objects | ||
go.animate("enemy1", "position.x", go.PLAYBACK_LOOP_PINGPONG, 720, go.EASING_INOUTQUAD, 5, 0) | ||
go.animate("enemy2", "position.x", go.PLAYBACK_LOOP_PINGPONG, 720, go.EASING_INOUTQUAD, 5, 0.5) | ||
go.animate("enemy3", "position.x", go.PLAYBACK_LOOP_PINGPONG, 720, go.EASING_INOUTQUAD, 5, 1) | ||
go.animate("enemy4", "position.x", go.PLAYBACK_LOOP_PINGPONG, 720, go.EASING_INOUTQUAD, 5, 1.5) | ||
end | ||
|
||
function on_input(self, action_id, action) | ||
if action_id == hash("left") then | ||
msg.post("timestep:/controller", "change_speed", { amount = -0.01 }) | ||
elseif action_id == hash("right") then | ||
msg.post("timestep:/controller", "change_speed", { amount = 0.01 }) | ||
elseif action_id == hash("action") and action.pressed then | ||
-- flip self.to between 0 and 3 each time | ||
self.to = 3 - (self.to or 0) | ||
msg.post("timestep:/controller", "animate_speed", { to = self.to }) | ||
end | ||
end |
Oops, something went wrong.