0 Favourites

draw lines between previous lines?

  • Hi. New to C2.

    I want the user to be able to swipe the screen either in an up(ish) or down(ish) move, and a line will begin to draw where they touched and spread from that point in 2 directions (left to right if they swiped horizontally for example). The line should stop drawing itself once it hits an immovable solid (like a previously drawn line or a block on the screen).

    Can't figure this out.

    Help!

  • Hmmm... my best thought is to make a sprite for your line. Make sure the sprite's origin point is at one of the ends of the sprite. You'll actually use two sprites with instance variables to "grow" the line with their origin ends touching and the "lines" facing opposite angles. Then use something like "Every tick - if Line.isgrowing - set Line height to Line.height+300*dt" to grow the lines. Then make a separate event for when the lines finally collide or overlap with one of your solid object and in there you set Line.isgrowing to false.

    edit: note the "dt" is just to make your lines not grow faster/slower when your framerate changes and makes inserting a pause function easier.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Thanks. That helped a lot :o)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Understanding Draw Calls.
42 2,991
newt's avatar
newt
Unread hot topic
0 Favourites
Hand-Drawn Games?
34 4,148
nemezes's avatar
nemezes
Unread hot topic
31 3,994
massivemonster's avatar
massivemonster