How do I scale something based on angle?

Get help using Construct 2

Post » Sun Jul 17, 2016 1:32 am

It's more complicated, and I can't offer the math off the top of my head, but you can simulate a skew with blending modes to create a mask for your arrow (which would actually be a rectangle, with two masks on top of it).

Just in case you were interested in a method without plugins.
Mistakes were made.
B
52
S
26
G
108
Posts: 1,606
Reputation: 61,133

Post » Sun Jul 17, 2016 2:05 am

I don't think I have an example, but the main feature to use is the paste action. The paste action will draw another object onto itself where the objects overlap.

So basically place a paster object on the layout.
Change it's hotspot to centered in the properties panel.
Position it over the triangle so that no matter which angle it faces the paster will still cover the arrow completely.
Remember the height of the paster. For this example let's say it's 200.

In events do this:

Every tick
--- paster: clear to (0,0,0,0)
--- paster: set height to 200
--- Sprite: set visible
--- paster: paste Sprite
--- paster: set invisible
--- paster: set height to 200/2

And that's about it. I hid the triangle Sprite after drawing it to the paster since we don't want it to draw again.
B
92
S
32
G
109
Posts: 5,290
Reputation: 70,991

Post » Sun Jul 17, 2016 10:55 am

Thanks @R0j0hound I will try that as well.
Follow my progress on Twitter
or in this thread Archer Devlog
B
40
S
17
G
17
Posts: 978
Reputation: 12,628

Post » Sun Jul 17, 2016 11:49 am

I managed to do it with CSS in C2 as well. I can't believe something so simple in CSS can be so hard to do in C2. Everything I need is a "RotateX" to get the squashed effect that I want. Can anyone with any deeper knowledge explain to me why these kind of transforms are not already built in to C2?

Textured button, rotated with CSS in C2:
Image

Image

Capx: If anyone want's to play around with it.
https://dl.dropboxusercontent.com/u/20560446/Scirra/3drotate.capx

@Ashley Is there any possibility that these kind of transforms will be available in any future update of C2, on regular objects such as sprites, Spritefonts and even Layers, etc? It would be a great addition and very useful.
Follow my progress on Twitter
or in this thread Archer Devlog
B
40
S
17
G
17
Posts: 978
Reputation: 12,628

Post » Sun Jul 17, 2016 6:06 pm

Here's a the idea I mentioned previously.

Although I still lack the maths to get the edges at the correct angle... >_>

https://www.dropbox.com/s/fswym37e307i2 ... .capx?dl=0
Mistakes were made.
B
52
S
26
G
108
Posts: 1,606
Reputation: 61,133

Post » Sun Jul 17, 2016 6:18 pm

oosyrag wrote:Here's a the idea I mentioned previously.

Although I still lack the maths to get the edges at the correct angle... >_>

https://www.dropbox.com/s/fswym37e307i2 ... .capx?dl=0


Nice example. That's pretty neat. I managed to make a kind of workaround by having an animated sprite. The sprite has 50 frames and changes the frames based on rotation, but the position is placed in a elliptical orbit around the player.

Turned out like this.
Image
Follow my progress on Twitter
or in this thread Archer Devlog
B
40
S
17
G
17
Posts: 978
Reputation: 12,628

Post » Sun Jul 17, 2016 7:39 pm

That looks fantastic. Simple solution is best.
Mistakes were made.
B
52
S
26
G
108
Posts: 1,606
Reputation: 61,133

Post » Mon Jul 18, 2016 10:37 am

tunepunk wrote:@Ashley Is there any possibility that these kind of transforms will be available in any future update of C2, on regular objects such as sprites, Spritefonts and even Layers, etc? It would be a great addition and very useful.

Those are 3D transforms, which amounts to making a 3D engine, so probably not.
Scirra Founder
B
397
S
236
G
88
Posts: 24,408
Reputation: 194,506

Post » Mon Jul 18, 2016 10:41 am

Ashley wrote:
tunepunk wrote:@Ashley Is there any possibility that these kind of transforms will be available in any future update of C2, on regular objects such as sprites, Spritefonts and even Layers, etc? It would be a great addition and very useful.

Those are 3D transforms, which amounts to making a 3D engine, so probably not.


Understood. How about independent X&Y scale for layers so you can get a similar effect?
Follow my progress on Twitter
or in this thread Archer Devlog
B
40
S
17
G
17
Posts: 978
Reputation: 12,628

Post » Mon Jul 18, 2016 10:43 am

That's not the same effect since there's no perspective. IIRC this came up before but it adds some pretty difficult complications to the engine when it has to work with other features like rotation and parallax, so I'd rather not add that.
Scirra Founder
B
397
S
236
G
88
Posts: 24,408
Reputation: 194,506

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 23 guests