-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from bytestring-net/dev
Docs and example improvements
- Loading branch information
Showing
31 changed files
with
282 additions
and
145 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 |
---|---|---|
@@ -1,33 +1,33 @@ | ||
# Summary | ||
|
||
[Introduction](1_overview.md) | ||
[Introduction](overview.md) | ||
|
||
--- | ||
|
||
# Getting started | ||
|
||
- [Installation](2_installation.md) | ||
- [Quick start](3_quick_start.md) | ||
- [Debug](4_debug.md) | ||
- [Installation](installation.md) | ||
- [Quick start](quick_start.md) | ||
- [Debug](debug.md) | ||
|
||
--- | ||
|
||
# Advanced | ||
- [Linking](advanced/0_linking.md) | ||
- [Layouts](advanced/1_layouts.md) | ||
- [Units](advanced/2_units.md) | ||
- [Cursor](advanced/3_cursor.md) | ||
- [Text](advanced/4_text.md) | ||
- [Abstraction](advanced/5_abstraction.md) | ||
- [Components](advanced/abstraction/1_components.md) | ||
- [Routes](advanced/abstraction/2_routes.md) | ||
- [Interactivity](advanced/6_interactivity.md) | ||
- [Animation](advanced/7_animation.md) | ||
- [2D & 3D](advanced/8_2d_and_3d.md) | ||
- [Worldspace UI](advanced/9_worldspace_ui.md) | ||
- [Custom rendering](advanced/10_rendering.md) | ||
- [Linking](advanced/linking.md) | ||
- [Layouts](advanced/layouts.md) | ||
- [Units](advanced/units.md) | ||
- [Cursor](advanced/cursor.md) | ||
- [Text](advanced/text.md) | ||
- [Abstraction](advanced/abstraction.md) | ||
- [Components](advanced/abstraction/components.md) | ||
- [Routes](advanced/abstraction/routes.md) | ||
- [Interactivity](advanced/interactivity.md) | ||
- [Animation](advanced/animation.md) | ||
- [2D & 3D](advanced/2d_and_3d.md) | ||
- [Worldspace UI](advanced/worldspace_ui.md) | ||
- [Custom rendering](advanced/rendering.md) | ||
|
||
----------- | ||
|
||
[Contributors](5_contributors.md) | ||
[Help](6_help.md) | ||
[Contributors](contributors.md) | ||
[Help](help.md) |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,83 @@ | ||
# Cursor | ||
|
||
Lunex provides a custom abstraction for a cursor related features within your Bevy application. | ||
This is achieved by moving all logic to a an entity that is spawned into the world. | ||
It is required that you spawn this entity, otherwise picking won't work. | ||
|
||
### Requirements | ||
|
||
You need to spawn this bundle for native cursor to work | ||
|
||
```rust | ||
commands.spawn( CursorBundle::default() ) | ||
``` | ||
|
||
### Styled cursors | ||
|
||
You can also attach custom image to your cursor entity. First, you will also need to have all the cursor icons in a image strip like this: | ||
|
||
![Cursor](../images/cursor.png) | ||
|
||
Then you can use `StyledCursorBundle` instead of `CursorBundle`. | ||
|
||
```rust | ||
commands.spawn(StyledCursorBundle { | ||
// Put texture atlas and sprite bundle here | ||
..default() | ||
}) | ||
``` | ||
|
||
Make sure you spawn `StyledCursorBundle` as a child of 2D `Camera`, otherwise the sprite would not follow the view. | ||
|
||
### Gamepad support | ||
|
||
To bind a cursor to a gamepad, you have to add this component: | ||
|
||
```rust | ||
GamepadCursor::new(0), | ||
``` | ||
|
||
If you want the cursor to accept both Mouse and Gamepad inputs, you have to create an additional | ||
system that listens to recent input events and based on them "removes" or "adds" this component. | ||
|
||
Currently, there is only 1 mode supported and that is `Free` which means you just use your stick to move | ||
the cursor around. There is no "jumping" yet. | ||
|
||
However, it is planned to add `Snap` mode, which makes the cursor "jump" and snap to the next node in input direction. | ||
|
||
## Example | ||
|
||
Here's an example of how to set up a custom cursor with gamepad control: | ||
|
||
```rust | ||
// Spawn cursor | ||
camera.spawn (( | ||
StyledCursorBundle { | ||
// Here we can map different native cursor icons to texture atlas indexes and sprite offsets | ||
cursor: Cursor2d::new() | ||
.set_index(CursorIcon::Default, 0, (14.0, 14.0)) | ||
.set_index(CursorIcon::Pointer, 1, (10.0, 12.0)) | ||
.set_index(CursorIcon::Grab, 2, (40.0, 40.0)), | ||
// Add texture atlas to the cursor | ||
atlas: TextureAtlas { | ||
layout: atlas_layout.add(TextureAtlasLayout::from_grid(UVec2::splat(80), 3, 1, None, None)), | ||
index: 0, | ||
}, | ||
// Add sprite strip to the cursor | ||
sprite: SpriteBundle { | ||
texture: assets.load("cursor.png"), | ||
transform: Transform { scale: Vec3::new(0.45, 0.45, 1.0), ..default() }, | ||
sprite: Sprite { | ||
color: Color::YELLOW.with_alpha(2.0), | ||
anchor: Anchor::TopLeft, | ||
..default() | ||
}, | ||
..default() | ||
}, | ||
..default() | ||
}, | ||
|
||
// Here we specify that the cursor should be controlled by gamepad 0 | ||
GamepadCursor::new(0), | ||
)); | ||
``` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,24 @@ | ||
[package] | ||
name = "worldspace" | ||
authors.workspace = true | ||
version.workspace = true | ||
edition.workspace = true | ||
publish = false | ||
|
||
[dependencies] | ||
bevy = { version = "^0.14.0", default_features = false, features = [ | ||
"bevy_asset", | ||
"bevy_winit", | ||
"bevy_core_pipeline", | ||
"bevy_pbr", | ||
"bevy_render", | ||
"bevy_sprite", | ||
"bevy_text", | ||
"multi_threaded", | ||
"png", | ||
"hdr", | ||
"vorbis", | ||
"x11", | ||
"tonemapping_luts", | ||
] } | ||
bevy_lunex = { workspace = true, features=["debug"] } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.