R0J0hound's Recent Forum Activity

  • Here's a better approach I found after the link above.

    You set the viewport size to the size you want.

    Next scroll to the center of what you want to capture.

    Then use the snapshot canvas action.

    When it's done you can then set the viewport back to normal and scroll back so it's centered.

  • Setting the ball's bullet setting to yes should fix the ball going through the paddle.

  • It would be a nice feature if you could use a string to set the color instead of a number, since the rgb() expression just returns a number.

    I guess in the meantime you could make a function like this to convert a rgb string to a number.

    on function "rgbText"

    --- set return value to rgb(int(mid(tokenat(function.parameter(0), 0, ","), 4, 3)), int(tokenat(function.parameter(0), 1, ",")), int(tokenat(function.parameter(0), 2, ",")))

  • Just guess but by default the stepping mode is fixed which means the timestep will be the same for every frame. So if the actual dt varies a lot frame to frame you'll get that jerking. You can change the stepping mode to variable which should help eliminate that.

    If it doesn't help then I'd guess an object with the bullet behavior moving at the same speed will have similar jerking. It's something that has come up before, and it's caused by how the browser used deals with your current hardware.

  • In construct classic arrays are 1 based as I recall. So the first element would be index 1 not 0.

  • Aldo

    Here's one way to do it. Basically loop over them and save the iid of the Sprite at the end of the loop so we can access it too at the next loop iteration using the sprite(1).x type syntax.

    Global variable prev=-1

    For each dot ordered by dot.x ascending

    ---- compare: loopindex>0

    -------- draw quad (dot(prev).x dot(prev).y, dot.x, dot.y, dot.x, 300, dot(prev).x, 300)

    ---- set prev to dot.iid

    An alternate way would be to store the positions in an array instead of that picking trickery.

    The quad points start with the top-left and go clockwise from there.

  • Not easily at least.

    You can take the positions and generate a layout.xml file using a layout xml from your capx as an example. So you'd save the generated file somewhere, close your project in c2, and assuming you had saved your project as a folder you can replace one of your project's layout xml with the one you generated. Unless there's a mistake in the xml that was generated.

    Anyways it's probably a tedious thing to do initially, and the step requiring you to manually replace files is a slow workflow.

    A more reasonable thing to do would be to save the generated positions to some text, and then put that into your game and recreate the objects from that.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's just an alternate idea of one doesn't want to use a third party behavior. Chipmunk does also recreate the shape but the velocity is retained. There isn't a crash if you do it continuously. All the old shapes should be cleaned up by the garbage colllector.

  • You can also save the velocity and angular speed to variables before setting the size and setting the velocty from the variables after.

  • Here's another example exploring what can be done:

    https://www.dropbox.com/s/4o28kqq4b30pb ... .capx?dl=1

    /examples34/spring.capx

    I commented it a lot and in many ways it's cleaner than what I've done before. I'm figuring it out as I go and unfortunately it would be too lengthy of a tutorial for me to write. Math used is some simple physics such as:

    distance = speed* time

    speed = acceleration * time

    acceleration = force*mass

    spring_force = -spring_constant * displacement

    damping_force = -damping_constant * relative_velocity

    Also vectors are used. addition, subtraction and dot product.

    The dot product is used to get the speed in a certain direction.

    Some simple trig is used too.

    x = radius*cos(ang)

    y = radius*sin(angle)

    The collision detection uses the dot product to get the distance from a line. Otherwise everything is a mix of that.

    There are two unsolved things in this:

    1. The spring mesh can be made to fold in on itself.

    2. The balls can teleport through walls if either are going fast enough.

  • The object getting stuck inside the floor is an unsolved problem currently. The collision response in the capx's was only partially solved.

    The springs are not done in a way specific to C2. You should be able to google spring physics tutorials to get the math explained. This may be a good source:

    https://www.khanacademy.org/science/phy ... ooke-s-law

  • There's an old example here:

    It's basically just springs.