How do you drag point list for custom shapes in canvas area?

hi its possible build custom shapes vertex dragging the vertex and change the form of a specific shape?.

What can be done with Canvas.DrawShape is limited Canvas

Draws a shape on the canvas. pointList should be a list contains sub-lists with two number which represents a coordinate. The first point and last point does not need to be the same. e.g. ((x1 y1) (x2 y2) (x3 y3)) When fill is true, the shape will be filled.

You cannot manipulate a shape while it is on the Canvas except by changing vertex coordinates. You cannot drag the vertex points unless you use Kevinkun's trick .. see below.. You can replace a point in the pointList ( x2 y2 ) becomes perhaps x2+1 y2) for example

by replacing that point. Might be able to do that with code and a drag of a ball. The drag seems to be restricted to dragging a sprite or ball . If you change the DrawShape, you will also have to clear the Canvas (redraw it) to display then new shape. :cry:


When the user does a drag from one point (prevX, prevY) to another (x, y). The pair (startX, startY) indicates where the user first touched the screen, and “draggedAnySprite” indicates whether a sprite is being dragged.

1 Like

so i need a extension o create a component for make that the drag works with point list no?

If I understood correctly, you want to draw a shape and use your finger to drag the vertices of that drawn shape?

yes this is the idea about my question.

See here

With straight lines it would be easy. But with a collection of points, and you don't know what the shapes are going to be, it can be very difficult.

  1. draw the lines /shape.
  2. show a ball on each intersection point.
  3. when a ball dragged, replace the corresponding coordinate in the list of the shape.
  4. clear canvas.
  5. repeat step 1.

Try this

Drag Ball To Highest Vertex (the first point in the pointList), then move the vertex With your Finger. Modify the code to make it do exactly what you want.

ShapeVertex.aia (2.7 KB)

Thank you @Kevinkun for the Ball drag idea. Works well with replacing coordinates in list Block.


This is a little game I make long time ago, to drag the balls to make the lines no intersection.


Here's a randomized version built on @SteveJG's base, reusing one Ball, headed towards what @Kevinkun did.

I see a lot of these little puzzles in casual games.

ShapeVertex.aia (5.0 KB)

1 Like

And here is a modification of @SteveJG example, without the ball.
ShapeVertex.aia (4.0 KB)