image draging works with scale now

This commit is contained in:
RustyStriker 2022-08-16 01:22:24 +03:00
parent 91e31fed7e
commit 5adc76505d
3 changed files with 6 additions and 4 deletions

View file

@ -18,7 +18,6 @@ Eventually, this will be a level editor... But until then, I guess it's just fun
- [x] Control images Z value(so we could reorder them) - [x] Control images Z value(so we could reorder them)
- [x] Delete images - [x] Delete images
- [x] Name images - [x] Name images
- [ ] Duplicate images(and also shapes maybe?)?
- [x] Scale images - [x] Scale images
- [x] Show hide shapes - [x] Show hide shapes
- [x] Control shape Z value - [x] Control shape Z value
@ -33,7 +32,9 @@ Eventually, this will be a level editor... But until then, I guess it's just fun
- [ ] Double click on shape in tree view will center the relevant shape - [ ] Double click on shape in tree view will center the relevant shape
- [ ] Grab shapes instead of center points - [ ] Grab shapes instead of center points
- [ ] Reorder items tree
## Maybe, just maybe todo ## Maybe, just maybe todo
- [ ] Group shapes/images under an empty/another object - [ ] Group shapes/images under an empty/another object with an actual tree view
- [ ] Duplicate shapes/images

View file

@ -61,9 +61,10 @@ pub fn modify_sys(
if let Some(size) = assets.get(h).map(|x| x.size()) { if let Some(size) = assets.get(h).map(|x| x.size()) {
let size = size * 0.5; let size = size * 0.5;
let t = gtransforms.get(e).unwrap(); let t = gtransforms.get(e).unwrap();
let scale = t.to_scale_rotation_translation().0;
// Disregard rotations for now plz // Disregard rotations for now plz
let diff = (mouse_pos - t.translation().xy()).abs(); let diff = (mouse_pos - t.translation().xy()).abs();
if diff.x < size.x && diff.y < size.y { if diff.x < size.x * scale.x && diff.y < size.y * scale.y {
*holding = Holding::Image(e, mouse_pos - t.translation().xy()); *holding = Holding::Image(e, mouse_pos - t.translation().xy());
break; break;
} }

View file

@ -1,7 +1,7 @@
use bevy::math::{Vec3Swizzles, Mat2}; use bevy::math::{Vec3Swizzles, Mat2};
use bevy::prelude::*; use bevy::prelude::*;
use bevy_egui::{egui, EguiContext}; use bevy_egui::{egui, EguiContext};
use bevy_prototype_lyon::prelude::{Path, DrawMode, FillMode, StrokeMode}; use bevy_prototype_lyon::prelude::{Path, DrawMode};
use crate::*; use crate::*;
#[derive(Default, Deref, DerefMut, Clone)] #[derive(Default, Deref, DerefMut, Clone)]