How do I draw a solid "line" with finger? [SOLVED]

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

    I try to make a solid line wich has to be drawn with the player's finger (something like that play.google.com/store/apps/details

    But, i have 2 main issues, i've created a little sprite (10x10) and assigned the Solid and the Physics behaviour to it,

    now i try to draw like this :

    the main issue is: when i'm moving my finger fast, the sprites are not drawn side by side but with a huge distance between each ones

    The second issue is: i cant "fix" em all so they act as a solid path

    Thank you so much for your help :D

    Edit: Link to the solution https://www.construct.net/en/forum/construct-3/how-do-i-8/draw-solid-line-finger-157441/page-2#forumPost1031100

  • edit1: sorry the url is not shown correctly: https://play.google.com/store/apps/details?id=com.orbital.brainiton https://play.google.com/store/apps/details?id=com.orbital.brainiton

  • you can do probably something like it.. i'm not sure how to do exactly what you did, but i made this game drawing a line with your finger.

    play.google.com/store/apps/details

    basically you have to spawn a dot every tick while finger is in contact in the position the touch is at.

  • Hi Part12studios and thank you for this answer !!

    i've tried this solution but this wasnt as accurate as i wanted soo i did it like this:

    1/ draw a first sprite on the very first touch

    2/ compute distance between the last sprite created and current touch position

    3/ repeat N times (where N is the result of the division of the distance by a global variable "distanceBetweenPoints")

    4/ and inside the repeat loop i'm drawing a point at lastSprite.X and lastSprite.Y + define position by angle where angle = the relative angle to current touch point, and distance = "distanceBetweenPoints"

    I hope it's clear :D

    with this method the line is very smooth :D

    My last problem is to find a way to "pin" each points with the last one created

  • there are way better construct guys out there, but my first thought would be that either we do some of "pin to object" thing where you have a container object that's invisible and all of the spawned objects are pinned to that invisible object.. when you let go physics of that invisible object is what falls and all those pinned objects should move with it.

    dropbox.com/s/hxu80vdm3cbeja8/pin%20example.c3p

  • something i learned i this example is not to pin with each spawn, but to actually have all of them "pin" when you release.. a single pin action at the moment you want them to then attach to the object..

  • though now the trick is how to make those black dots interact with other objects by not each other.. i'm looking into that now. there must be a way to have physics but only physics with other objects not like objects.

  • hmmm the challenge is how all of the spawned dots that are drawn to then be considered one single mesh object.. and have collision detectors that conform to the shape of that object.. i'm not sure if construct has that level of control over grouping stuff. because it means the bounding boxes the new shape has to be determined at the moment of touch release..

    maybe using something like families.. it's critical that there has to be some way to allow these objects to overlap each other being physics objects and yet not try to push away from each other when physics collision is enabled.. like if there was some tag or something that could be used to basically say "collide with anything else except things with this tag.."

  • there is some kind of solid collision filter.. i can't get it to work but if you can figure out how to use tags to ignore one object (other pieces of line) but collide with everything else you should be good to go. good luck!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Is this what you are trying to make?

    https://howtoconstructdemos.com/physics-game-draw-lines-to-catch-falling-objects-capx/

    Here is another example:

    https://howtoconstructdemos.com/draw-a-path-on-the-screen-and-move-your-character-along-it/

    Yes thank you ! the first one is exactly what i need, just missing the physics part

    the aim is to "pin" each points to the preceding so i can apply gravity to the drawing

    The second is good to keep if needed one day xD

  • there are way better construct guys out there, but my first thought would be that either we do some of "pin to object" thing where you have a container object that's invisible and all of the spawned objects are pinned to that invisible object.. when you let go physics of that invisible object is what falls and all those pinned objects should move with it.

    https://www.dropbox.com/s/hxu80vdm3cbeja8/pin%20example.c3p?dl=0

    OMG i dont even know why i didnt think about that, THANK YOU it's a good track i guess !

    But this would prevent the drawing to be subject to gravity, no ?

  • there is some kind of solid collision filter.. i can't get it to work but if you can figure out how to use tags to ignore one object (other pieces of line) but collide with everything else you should be good to go. good luck!

    Thank you so much for your help and tips!!!

    I would dig on the way you gaved to me and i would post an eventual "solution" here :D

    Thank you all for your help !

  • awesome good luck.. glad to help a little.

  • Well, i dont find the way to apply gravity to the whole drawing :(

    i tried many ways but none of them works correctly,

    please find my test project attached, if anyone could help please :D

    ps: the start is good, but when the mouse is released, nothing is pinned and all of the "points" are independant

    https://www.dropbox.com/s/1qiq0hfkvkeknle/drawtest2.c3p?dl=0

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