HaxeFlixel / flixel

Free, cross-platform 2D game engine powered by Haxe and OpenFL
https://haxeflixel.com/
MIT License
1.97k stars 434 forks source link

Improve FlxSwipe #1895

Open DleanJeans opened 8 years ago

DleanJeans commented 8 years ago

Right now, FlxSwipes are only created after mouse or touch is released, which is not how I expected them to work. So I decided to improve it a little: a FlxSwipe will be created as soon as a mouse button or touch is down and kept in FlxG.swipes until mouse/touch is released and its endPosition is updated every frame. And I'm feeling like this is not enough. I think FlxSwipe also needs a threshold since a click or a tap is also counted as a swipe. What about a swipe going in different directions (like circling, ping pong)? Should we add FlxPoints between start and end position like a path?

DleanJeans commented 8 years ago

I think I should just close this. Since updating endPosition would just unnecessarily decrease the performance, maybe.

Gama11 commented 8 years ago

Since updating endPosition would just unnecessarily decrease the performance, maybe.

Which part of that do you think would be expensive?

DleanJeans commented 8 years ago

maybe.

Perhaps it's not that expensive. I was just trying to implement something like FlxScrollableArea but with swipe-to-scroll for mobile target (for a friend). And FlxSwipe isn't enough for this and seems like I'm the only one who has talked about this.

Tembac commented 8 years ago

I found this problem now. I'm trying to do a level map for a mobile game that can be scrolled using touches and swipes. But I think that swipes are not measured correctly by HaxeFlixel.

If I pressed the mouse button down and move the mouse around for a few seconds the swipe is taking the first point of click and the last as the swipe points. But the last swipe really was different. I think that swipes need to be measuring the starting point every a few second or when it drastically changes direction.

I'm not sure yet where Flixel is handling swipes so I'm not sure how to fix it.