TouchScrolling
TouchScrolling copied to clipboard
How can I use this scroll?
Hi, Pavel!
Yesterday, I'm started to use your TouchScrolling library, but I still can't understand, how to work with it correctly. Could you help, please?
I have a Sprite in a FlashDevelop project and I want to scroll it. I use the code:
private var touchScroller:TouchScrollModel; ... touchScroller = new TouchScrollModel(); touchScroller.setViewportSize(stage.stageWidth, stage.stageHeight);
What should I do next? How to link sprite with touchScroller?
I've also tried to use TouchScroller class as follows:
private var touchScroller:TouchScroller; ... touchScroller = new TouchScroller(); addChild(touchScroller);
and have few errors:
- TouchScrollManager.as(1797): col: 57 Error:
- TouchScrollManager.as(1816): col: 40 Error:
- TouchScrollManager.as(1857): col: 41 Error:
- TouchScrollManager.as(1903): col: 38 Error: Type was not found or was not a compile-time constant: PanGestureEvent.
Please, support me, how can I correctly use your TouchScroller library?
Thanks in advance!
https://github.com/fljot/Gestouch PanGestureEvent
At 2014-10-23 21:37:45, "soniko" [email protected] wrote:
Hi, Pavel!
Yesterday, I'm started to use your TouchScrolling library, but I still can't understand, how to work with it correctly. Could you help, please?
I have a Sprite in a FlashDevelop project and I want to scroll it. I use the code:
private var touchScroller:TouchScrollModel; ... touchScroller = new TouchScrollModel(); touchScroller.setViewportSize(stage.stageWidth, stage.stageHeight);
What should I do next? How to link sprite with touchScroller?
I've also tried to use TouchScroller class as follows:
private var touchScroller:TouchScroller; ... touchScroller = new TouchScroller(); addChild(touchScroller);
and have few errors:
TouchScrollManager.as(1797): col: 57 Error: TouchScrollManager.as(1816): col: 40 Error: TouchScrollManager.as(1857): col: 41 Error: TouchScrollManager.as(1903): col: 38 Error: Type was not found or was not a compile-time constant: PanGestureEvent.
Please, support me, how can I correctly use your TouchScroller library?
Thanks in advance!
— Reply to this email directly or view it on GitHub.
@soniko @fykyx521 guys, the demo is not working anymore. I started to refactor the lib, but it's slightly abandoned now (should work though, can't say if totally stable).
Will speak only for this branch https://github.com/fljot/TouchScrolling/tree/features/decoupled-architecture
So there's this model TouchScrollModel, which does all the calculations based on your input. So you need to configure it:
- You need to tell it the min&max scroll position. You can do it via setContentSize and setViewportSize OR by seting scrollBounds excplicitly (if you prefer to calculate it urself, e.g. having negative values).
2, Specify callbacks to be executed when scroll position will be recalculated (during dragging or throw): positionUpdateCallback throwCompleteCallback
- Configure other behaviours if you like (see public vars).
I'm sorry, but you will need to dig into code a bit as I don't have documentation or examples.
So the first part – configuration – is done.
Now you need to update model when you interact with your interactive object. Call methods onInteractionBegin (when you touch), onDragBegin (when you drag first time!), onDragUpdate (when you drag), onInteractionEnd. These methods will update model's internal physics and calculated positions will come to positionUpdateCallback and throwCompleteCallback you specified.
This way this model is totally independent from rendering (e.g. you can use it for regular sprites, for flex or custom components, for Stage3D engines – whatever).
Feel free to share your progress and help each other. I'm busy, but could help you in case you stuck.