How do I draw shape with dynamic polygon

Get help using Construct 2

Post » Thu Apr 19, 2018 10:56 pm

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.
Image
B
58
S
16
G
3
Posts: 275
Reputation: 6,271

Post » Thu Apr 19, 2018 11:03 pm

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.
B
101
S
39
G
134
Posts: 5,591
Reputation: 85,520

Post » Fri Apr 20, 2018 2:33 am

@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. :)
Learning other engines, but C2 still rocks. Image Image Image Image
B
81
S
22
G
96
Posts: 2,468
Reputation: 58,353

Post » Sat Apr 21, 2018 6:02 am

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

R0J0hound wrote: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.
Image
B
58
S
16
G
3
Posts: 275
Reputation: 6,271

Post » Sat Apr 21, 2018 6:05 am

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

Colludium wrote:@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. :)
Image
B
58
S
16
G
3
Posts: 275
Reputation: 6,271

Post » Sat Apr 21, 2018 6:29 am

B
101
S
39
G
134
Posts: 5,591
Reputation: 85,520

Post » Sat Apr 21, 2018 8:11 am

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.
Learning other engines, but C2 still rocks. Image Image Image Image
B
81
S
22
G
96
Posts: 2,468
Reputation: 58,353

Post » Sat Apr 21, 2018 8:33 am

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
Image
B
58
S
16
G
3
Posts: 275
Reputation: 6,271

Post » Sat Apr 21, 2018 8:58 am

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.. :)
Learning other engines, but C2 still rocks. Image Image Image Image
B
81
S
22
G
96
Posts: 2,468
Reputation: 58,353

Post » Sat Apr 21, 2018 9:05 am

this looks amazing,
Image
B
58
S
16
G
3
Posts: 275
Reputation: 6,271


Return to How do I....?

Who is online

Users browsing this forum: j1elliott and 1 guest