User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: Drag & drop decelleration example

  1. #1
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,139
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Drag & drop decelleration example

    Lots of people seem to be asking for this and a lot of the examples are iffy, I thought I'd show you guys how I've always done it. I've commented the events to try to make it nice and easy to understand how it works.

    - The method of detecting the speed of the drag and then decelerating can be reverse-engineered into dragging the screen with a bit of work.
    - You can very easily add gravity to this by always adding to Y Speed when the object isn't being dragged.
    - The object can be made to 'bounce' from the sides of the screen by reversing it's X Speed and Y Speed (multiply it by -1).
    - The counters at the top display the X and Y speed and the 'Always' event in the main frame controls them, everything else is inside of the object's behaviour, so you can use it as a widget.
    - Detecting the speed of the drag in this way can have all kinds of applications - for example detecting the force and direction of a slice in Fruit Ninja.
    Attached files Attached files

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    Fanotherpg's Avatar
    Join Date
    Jul 2006
    Location
    High Wycombe, Buckinghamshire, UK
    Posts
    3,665
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quite interesting example DistantJ. Thanks for sharing with it!

  3. #3
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,139
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    No problem, thanks for responding

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module

    Join Date
    Mar 2010
    Location
    Lier, Norway
    Posts
    276
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    This example is great!
    Is there a way to make the screen scroll to the nearest center of a screen when releasing the mouse/touch? like if this was a level select with 3 screens.. (160,480,800 etc)

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,139
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yeah, give me a while and I'll sorr out an example for that. It'll be in my touch scrolling with momentum thread.

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module

    Join Date
    Mar 2010
    Location
    Lier, Norway
    Posts
    276
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Nice! Thanks!

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Tuna's Avatar
    Join Date
    Feb 2008
    Location
    Central Texas
    Posts
    1,853
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I'd like this to not snap to the touch point... how can i prevent my object from snapping?

  8. #8
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,139
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You need to compare the position of the object to the position of the touch, and add/subtract the difference.

    For example you might, say, detect the start of the touch on the object (user clicks on object), then store the distance in values, let's say Xdifference = X('object')-XMouse, Ydifference = Y('object')-YMouse, then use those values to position it, i.e. set X co-ordinate to XMouse+Xdifference, set Y co-ordinate to YMouse+Ydifference.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export Module
    foyzul2002's Avatar
    Join Date
    Nov 2011
    Location
    London, UK
    Posts
    109
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @DistanJ This is really good, I think I actually asked for this and of the forum members kindly created a solution for me.

    Now, what I've been trying to do is a kind of 'swipe' feature, where the player can't just drag the object to the target, and has to be swiped so this object slides to the target. Any ideas if this can be done? I'm not too good with the more complicated stuff and end up doing something really complicated and inefficient to get my solution.

  10. #10
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,139
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Hm, you mean like sort of 'flicking' the object, but not being able to drag it? Hmm...

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Drag and drop movement- force drop action
    By qenio in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 7th April 2013, 09:53 PM
  2. Drag & drop without drag & drop object.
    By soloman in forum Multimedia Fusion 2 - Technical Support
    Replies: 9
    Last Post: 20th August 2011, 02:45 AM
  3. Drag and drop bug
    By Viewtiful in forum File Archive
    Replies: 0
    Last Post: 30th June 2010, 03:22 AM
  4. Drag n Drop
    By faeriebass in forum Multimedia Fusion 2 - Technical Support
    Replies: 14
    Last Post: 23rd July 2009, 07:23 PM
  5. Drag N' Drop Bug
    By Shroomlock in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 22nd April 2008, 08:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •