Cutting objects

For questions about using Classic.

Post » Fri Mar 30, 2012 4:25 pm

So i have an object with the physics behavior, and i want to split it into two physics objects,of the same type by drawing a line over it.I know how to make the line, i just cant figure out how to split the object correspondingly to the line.
Hers's a picture: http://dl.dropbox.com/u/52670878/cut.png
I suppose i have to use the canvas object somehow...
Any help or ideas on how to do this would be appreciated.Thanks in advance.
B
6
S
1
G
1
Posts: 69
Reputation: 1,019

Post » Fri Apr 06, 2012 7:38 pm

No one? Ah, well i guess i should be proud i discovered something that's impossible to do in construct...
B
6
S
1
G
1
Posts: 69
Reputation: 1,019

Post » Fri Apr 06, 2012 8:22 pm

It's partially doable, you can use the canvas plugin to draw the shapes but you wouldn't be able to use the physics behavior since you can't change the collision polygon a runtime.

An approach for the splitting of a polygon by a line mechanic is explained here:
http://stackoverflow.com/questions/3623703/how-can-i-split-a-polygon-by-a-line
http://en.wikipedia.org/wiki/Line-line_intersectionR0J0hound2012-04-06 20:22:45
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Sat Apr 07, 2012 11:32 am

Thanks for replying rojohound but for those tutorials the problem is that i don't have lines intersecting, but an object and a line...

How can i use the canvas plugin to make two different objects? I don't see a way to load animation frame from canvas.
B
6
S
1
G
1
Posts: 69
Reputation: 1,019

Post » Sat Apr 07, 2012 7:55 pm

I missed the fact that this was in the Construct Classic section.

In CC here is a way to slice up an image into separate pieces:
http://dl.dropbox.com/u/5426011/examples10/sliceCanvas.cap
It doesn't remove the issue of making it work with physics. Physics uses polygon collisions not pixel collisions, so the links I posted are still relevant.

To use physics the approach I would take is use some python working with pyBox2d or pymunk.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Mon Apr 09, 2012 9:47 pm

That's an excellent example(idea) rojohound,thank you very much. One last question: how can I load the canvas' frame into a sprite object frame?
I don't know python, so i'll try to use the custom movement behavior to recreate the physics behavior somehow, as a workaround for the collision masks.
B
6
S
1
G
1
Posts: 69
Reputation: 1,019

Post » Mon Apr 09, 2012 11:28 pm

You can copy the image of a Canvas to a Sprite with the ImageManipulator object. Specifically with the two actions "copy from sprite" and "copy to sprite". Even though it says sprite it will work for copying from a canvas.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Tue Apr 10, 2012 8:31 pm

Aah ok.Thanks again for the help rojohound, you're a pro.
B
6
S
1
G
1
Posts: 69
Reputation: 1,019


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests