Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.

Commit f9f0201

Browse files
committed
updated platformer tutorial
1 parent 1ba1bd1 commit f9f0201

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

Diff for: platformer/data/scene.rgs

7.78 KB
Binary file not shown.

Diff for: platformer/editor/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ version = "0.1.0"
55
edition = "2021"
66

77
[dependencies]
8-
fyrox = {path = "../../../Fyrox"}
9-
fyroxed_base = {path = "../../../Fyrox/editor"}
8+
fyrox = {path = "../../../Fyrox", version = "0.29"}
9+
fyroxed_base = {path = "../../../Fyrox/editor", version = "0.16"}
1010
platformer = { path = "../game" }

Diff for: platformer/executor/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ version = "0.1.0"
55
edition = "2021"
66

77
[dependencies]
8-
fyrox = {path = "../../../Fyrox"}
8+
fyrox = {path = "../../../Fyrox", version = "0.29"}
99
platformer = { path = "../game" }

Diff for: platformer/game/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ version = "0.1.0"
55
edition = "2021"
66

77
[dependencies]
8-
fyrox = {path = "../../../Fyrox", version = "0.28"}
8+
fyrox = {path = "../../../Fyrox", version = "0.29"}

Diff for: platformer/game/src/lib.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use fyrox::{
44
core::{
55
algebra::{Vector2, Vector3},
66
futures::executor::block_on,
7-
inspect::{Inspect, PropertyInfo},
87
pool::Handle,
9-
reflect::Reflect,
8+
reflect::prelude::*,
109
uuid::{uuid, Uuid},
1110
visitor::prelude::*,
1211
},
12+
engine::resource_manager::ResourceManager,
1313
event::{ElementState, Event, VirtualKeyCode, WindowEvent},
1414
impl_component_provider,
1515
plugin::{Plugin, PluginConstructor, PluginContext, PluginRegistrationContext},
@@ -72,7 +72,7 @@ impl Game {
7272

7373
impl Plugin for Game {}
7474

75-
#[derive(Visit, Inspect, Reflect, Debug, Clone)]
75+
#[derive(Visit, Reflect, Debug, Clone)]
7676
struct Player {
7777
sprite: Handle<Node>,
7878
move_left: bool,
@@ -137,9 +137,9 @@ impl ScriptTrait for Player {
137137
};
138138

139139
if x_speed != 0.0 {
140-
self.current_animation = 1;
141-
} else {
142140
self.current_animation = 0;
141+
} else {
142+
self.current_animation = 1;
143143
}
144144

145145
if self.jump {
@@ -178,17 +178,22 @@ impl ScriptTrait for Player {
178178
.and_then(|n| n.cast_mut::<Rectangle>())
179179
{
180180
// Set new frame to the sprite.
181+
sprite.set_texture(current_animation.texture());
181182
sprite.set_uv_rect(
182183
current_animation
183184
.current_frame_uv_rect()
184-
.cloned()
185-
.unwrap_or_default()
186-
.0,
185+
.unwrap_or_default(),
187186
);
188187
}
189188
}
190189
}
191190

191+
fn restore_resources(&mut self, resource_manager: ResourceManager) {
192+
for animation in self.animations.iter_mut() {
193+
animation.restore_resources(&resource_manager);
194+
}
195+
}
196+
192197
// Returns unique script id for serialization needs.
193198
fn id(&self) -> Uuid {
194199
Self::type_uuid()

0 commit comments

Comments
 (0)