User Tag List

Results 1 to 6 of 6

Thread: How would you move an object in straight line pixel by pixel from location to another

  1. #1
    Clicker Multimedia Fusion 2SWF Export Module
    Tsun's Avatar
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How would you move an object in straight line pixel by pixel from location to another

    I have an object, and I want to move it from one point to another. I want to move it one pixel at a time in a fast loop, and so that it goes in a straight line from point A to point B. I want to add an action every time it moves a pixel, so that's why pixel by pixel.

    I suppose this requires some kind of mathematical calculation, but I can't figure it out. I tried calculating some kind of ratio, as in for example "move it in X axis every 0.25 times and move in Y the rest", but it becomes difficult since the point B might be either in negative or positive X or Y axis.

    Any ideas?

  2. #2
    Forum Moderator

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUniversal Windows Platform Export ModuleSWF Export ModuleXNA Export ModuleInstall Creator Pro
    nivram's Avatar
    Join Date
    Jul 2006
    Location
    Bandon, Oregon
    Posts
    6,773
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    You know how a player pushes a box? Can you somehow translate that?

    Just a thought,
    Marv
    ​458 TGF to CTF 2.5+ Examples and games
    http://www.castles-of-britain.com/mmf2examples.htm

  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,144
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Well if you're doing a horizontal or vertical line it's straight up add/subtract 1 to X/Y but I'm sure you already know that. What you need is to move it diagonally, right?

    Look up Sine and Cosine, there's a trigonometry tutorial floating around, might be on Marv's site.

  4. #4
    Clicker Multimedia Fusion 2SWF Export Module
    Tsun's Avatar
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it possible to use sine/cosine to move it that way?

    I want to add an action every time it moves one pixel, for example launch a bullet. Easy enough until you need to move in diagonal angles different from 45° divisions.

  5. #5
    Clicker Multimedia Fusion 2SWF Export Module
    Tsun's Avatar
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After a lot of guessing and experimenting, I managed to do it, and there is yet another app that even the developer would have trouble replicating. :P

  6. #6
    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,144
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    How would you move an object in straight line pixel by pixel from location to another

    You basically use trig to work out how much to move horizontally and vertically, so you treat it like you're finding out the sides of a triangle when you know the hypotenuse length.

Similar Threads

  1. Get size in pixel of a string (or convert string length to pixel)
    By iOSC in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 21st March 2013, 06:30 PM
  2. Beta 11: Moving buttons Pixel by Pixel
    By Kisguri in forum iOS Export Module Version 2.0
    Replies: 2
    Last Post: 16th January 2011, 08:54 AM
  3. Jump from walls pixel by pixel?
    By Carlos182 in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 29th September 2009, 05:15 AM
  4. Pixel-by-pixel destruction
    By pikzilla in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 29th May 2009, 09:11 PM
  5. Sub-Pixel Positioning Pixel Shader
    By LazyCoder in forum Hardware Accelerated Runtime
    Replies: 15
    Last Post: 16th March 2008, 11: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
  •