Draw a line between 2 points

0 favourites
  • 9 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Hi

    I want to draw a line between two points, yet have been unable to figure out a way to do that.

    My end game is to draw the path of the touch interface (or the mouse), in the same way it's done in Fruit Ninja.

    So far, my approach has been to create a small round object under the Touch coordinates, and then have it slowly die. This creates a trace like it's shown in the screenshot:

    <img src="http://s3.postimage.org/ej3f3dx0z/photo.png" border="0" />


    But this approach won't get me the pointy line that's wide at the front, and gradually gets thinner as it fades away.

  • Sorry if I misunderstood something, personally I would make an image of the slice.

    And then:

    • distance = abs(firstpoint.X - firstpoint.X) (so you get the size of the distance)
    • image set width to distance
    • image set position to firstpoint.x
    • image set angle

    you should also scale the height of the image a bit

    This would just be one way, there are better ones with particles, i try to find one

  • In the how do I FAQ

    => A dash/slash effect like in "Fruit ninja" - LINK

  • Wow, typed in a big explanation and my cookie expired. Sorry for this short one, but I need to get to work. I just lost 20 minutes of typing for some stupid security feature. Looks like 2 other people have made posts since I lost my work, sorry if I say something that has already been said, or if I am vague.

    Here is the file I made for you :


    in a nutshell, you spawn the sprite, have it set angle to Target.X and the Target.Y then you scale it until it hits the target. After it hits, then simply destroy it, or have it wait a split second and destroy.

    Put the origin on the far left of the sprite to set the scale point. Have it scale while it is on screen. Have it destroy once it collides with target.

  • demo: https://dl.dropbox.com/u/23551572/C2-Ga ... index.html

    capx: ninjaStroke.capx

    polygon plugin: polygon.zip

    polygon plugin topic: http://www.scirra.com/forum/topic62075.html

    should work with multi-touch but I have no devices so I couldn't test

  • Thanks to all for the info. Deeply appreciated!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi

    I basically cut&pasted the Kyatric's linked project, and got this.

    <img src="http://s7.postimage.org/5u479bszv/photo.png" border="0" />

    There's some kind of gap between each segment of the line. Actually is more like the Touch X&Y coordenates are not being red correctly (but when I run the linked project, things run fine) .

    Anyone has any idea why this could be happening?

  • .capx?

    What are your touch x/y values? You may want to try AbsoluteX/Y

  • Found the problem. It was the origin point not set to the left edge of the sprite.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)