How do I draw shape with dynamic polygon

0 favourites
  • 10 posts
From the Asset Store
You need this package if you want to program a Street Fighter or battle game.
  • https://play.google.com/store/apps/deta ... .brainiton

    Has anyone made this kind of game if yes how did you achieve dynamic polygon i.e. whatever shape you have drawn.

    I am trying using canvas but seems dynamic polygon is not possible.

  • i have an old example the you may be able to find that uses a JavaScript physics engine directly to do hand drawn shapes. The drawback is you have to do all physics objects that way. The behaviors don’t interact with it.

    There’s also a sold physics behavior that lets you do that. That’s all I know, I avoid buying stuff.

    A third way would be to modify one of the existing behaviors but this is out of scope to most.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • socialpilgrim, check out my Box2D+ plugin. It's based on the asm.js 2.3.0 version of Box2D and it contains features where you can set the collision shape from either the image alpha or you can directly inject the shape from a c2 array of vertex positions. Here's a demo of on-the-fly collision shape creation using it.

  • R0J0hound - could you share the link or capx if u have or post link.

    i have an old example the you may be able to find that uses a JavaScript physics engine directly to do hand drawn shapes. The drawback is you have to do all physics objects that way. The behaviors don’t interact with it.

    There’s also a sold physics behavior that lets you do that. That’s all I know, I avoid buying stuff.

    A third way would be to modify one of the existing behaviors but this is out of scope to most.

  • Thanks Colludium, looks it will work, let me comeback. I will try and test.

    socialpilgrim, check out my Box2D+ plugin. It's based on the asm.js 2.3.0 version of Box2D and it contains features where you can set the collision shape from either the image alpha or you can directly inject the shape from a c2 array of vertex positions. Here's a demo of on-the-fly collision shape creation using it.

  • I'm glad had it looks ok for your needs. It's got about the same performance as the standard ASM.js physics, so it s should perform ok on medium range mobiles. However, it doesn't work in cocoon.js accelerated wrapper.

  • Colludium - what about not closing polygon and just keeping like shape as it is, is it possible ?

    I saw in demo, everytime it is closing loop to make polygon but in actual i dont want

  • Everything in box2d has to be a fixture - a two dimensional shape (although single planes are possible in the library, I couldn't figure how to implement them in c2). So, to make lines that have width, you'd have to write that using events - I'll have a think about how that could easily be implemented in c2, but it'll be something like: with a line from x0, y0 to x1, y1 you determine the gradient and then the normal angle, then create a fixture with four corners positioned at the ends using geometry.

    Thinking about it, you could also do something similar with the standard physics library - create a rectangular sprite, size it to your line shape and then enable Physics. The challenge there would be to join multiple lines together - once you have joined more than a couple of objects you typically get joint fighting, which is a feature of all physics libraries.

    My Box2D+ has a unique 'assimilate' joint which allows you to join objects together by making one a parent and one or more others its children, with the shapes given to the parent body as new fixtures. The advantage is that there are no joints to cause fighting. Here's a Box2D+ assimilate joint demo - you can't do that with the normal physics engine..

  • this looks amazing,

  • it,s very easy ,you can spawn Square and circular sprite every some time when is touching, then pin Square and circular sprite! the square angle is need to caculate

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