Load a sprite from a url and control its collision polygon

Get help using Construct 2

Post » Fri Nov 21, 2014 10:45 am

Hello,

The manual states it possible to load a sprite using "Load image from URL". But can I control that sprite's collision polygon as well? Lets say the sprite image is of a triangle, will the sprite assume a triangle shape, with an appropriate collision polygon? Is is possible to invoke the Collision Polygon editor in runtime? Or even set the the polygon at runtime based on values downloaded from another source, like a socket connection to a server.

Ideally I would like to load a sprite from a server including data which defines its collision polygon.

Cheers,

Gez
B
4
S
1
Posts: 5
Reputation: 535

Post » Fri Nov 21, 2014 3:12 pm

Hi @Gez That sounds like it should be possible, based on the same mechanics that enable Construct 2 to guess the guess the polygon shape. Does anyone know if this is already possible or whether it needs a plugin?
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Fri Nov 21, 2014 9:29 pm

Thanks for the reply hundereddfold,

I had a hunt in user plugins and there is one called polygon which shows how to define a collision polygon

...
this.collision_poly = new cr.CollisionPoly
...

I will have a go at creating a new plugin

Cheers

Gez
B
4
S
1
Posts: 5
Reputation: 535

Post » Fri Nov 21, 2014 10:40 pm

You could pin the sprite with the new image to another (invisible) that holds the collision polygon you want, then use that for collision checking.
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,283
Reputation: 47,550

Post » Fri Nov 21, 2014 11:12 pm

@Colludium Yes, that would work, but only if you know the shape in advance. I believe a plugin that can "work out" the shape from the image would be of more use.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Fri Nov 21, 2014 11:16 pm

@hundredfold, ah - yes, I see. Some way of ensuring it is not given a default rectangle on import.
A big fan of JavaScript.
B
76
S
20
G
76
Posts: 2,283
Reputation: 47,550

Post » Fri Nov 21, 2014 11:30 pm

@Colludium yes, just like the "guess the polygon shape" feature works.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 9 guests