How do I fill in the gap?

0 favourites
  • 12 posts
From the Asset Store
An educational game for Fill in the Blanks. An easy to use template for developers to build larger games
  • Hello. Using physics, I have chained several objects together to form a ball. This lets it bounce and squish instead of staying a perfect circle.

    But the ball is hollow.

    Is there a way to overlay another object so that it's visible inside the ball shape, but transparent outside of it?

  • You can draw a polygon on Drawing Canvas, using the coordinates of your chain links.

  • Thank you for replying. That sounds like it would work, but I am having trouble using DrawingCanvas. After placing a DrawingCanvas on the layout, I tried a basic example to test it out.

    On start of layout

    - DrawingCanvas- Add polygon point

    - DrawingCanvas- Add polygon point

    - DrawingCanvas- Add polygon point

    - DrawingCanas- Fill polygon

    Just testing to make a simple triangle before trying it with the chain links, but a triangle is not drawn. Am I missing a step?

  • Oh, a circular mesh is also an option.

  • Just testing to make a simple triangle before trying it with the chain links, but a triangle is not drawn. Am I missing a step?

    Check that the coordinates are correct - they should be within the canvas width and height. (not layout coordinates)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Okay. Making progress. Two more steps needed.

    1. Right now, the canvas points are added at the x,y of the three yellow test rectangles. They need to be added within the boundaries of the canvas.

    2. The canvas is pinned, so it does move with the rolling ball, but the canvas points do not stay with the yellow x,y. The triangle stays static.

  • As mentioned above the drawing canvas uses xy coordinates relative to the canvas not normal layout coordinates.

    What that means is instead of adding points at (sprite.x,sprite.y) you need to do (sprite.x-drawingcanvas.bboxLeft, sprite.y-drawingcanvas.bboxtop)

  • Thank you very much.

  • I got the drawing canvas to work, but I do not like the effect.

    How would I use the yellow squares as the points for a mesh?

  • The basic idea is to take a distort mesh and wrap it into a circle. Take a sprite and give it a mesh size of 33x2. Then the first row will be set to the edge sprite positions, and the second row will be set to the midpoint of all the edge sprites. You can also set the uvs of the mesh points so that when the shape is a circle the image isn't distorted at all.

    I needed a testbed for an example, so I tried to replicate the ball from boxes connected by joints. Ended up using two sprite types to do that since the free version doesn't have families. I'm guessing you used limited revolute joints to connect the objects. That did give soft ball behavior, but it seemed to be adding energy which caused the ball to spin off to the left or right. It was related to the order the joints were added. I imagine adding the joints in a balanced way could help but instead I used normal revolute joints and distance joints which gave more tuning control of how springy the ball was.

    Anyways, here is the example of one way to distort the mesh to a circle.

    dropbox.com/scl/fi/2vktya0r9fqji0hft5qfo/physics_ball.c3p

  • Oh, wow! That is marvelous. Thank you very much.

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