For developers using the Construct 2 Javascript SDK

Post » Mon Dec 02, 2013 7:58 pm

Hi guys,

in r150 quadTexUV was introduced. It vaguely states "New quadTexUV function in WebGL renderer for plugins to use for distortion effects".

What can we expect do with it and how?
Do we get updated SDK-templates in the near future?

It seems pretty interesting and my guess is that we are able to code something like this:

Posts: 95
Reputation: 4,312

Post » Mon Dec 02, 2013 9:19 pm

It allows you to draw a quad using an arbitrary part of a texture.

This is the definition of the function.
[code]quadTexUV = function(tlx, tly, trx, try_, brx, bry, blx, bly, tlu, tlv, tru, trv, bru, brv, blu, blv)[/code]

The first two letters of the parameters indicate what corner of the quad it defines. For example tlx is "top-left x", bru is "bottom right u". So for four points you have x,y,u and v. x and y is the point's position on the layout and u,v is the texture position of a texture which are in the range of 0 to 1. Where for u 0 is the left side of the texture and 1 is the right. For v 0 is the top of the texture and 1 is the bottom.

It's basically like uv editing in 3d modeling programs except there is no z so the example you referenced isn't possible.

To use it call it in you drawgl function with glw.quadTexUV. To my knowledge there isn't a plugin that uses it yet. quadTex is used however to use a sub-rectangle of a texture. The sprite object uses it when animations are exported to spritesheets. I have also used it in my spritesheet plugin.
Posts: 5,294
Reputation: 70,999

Post » Tue Dec 03, 2013 12:35 pm

Thanks for the description @R0J0hound! I'd add the normal quadTex function only allows you to specify texture co-ordinates as a rectangle, but quadTexUV allows you to specify the exact four texture co-ordinate points. This is useful for things like mesh distortion, and we actually ended up using it in the Tilemap plugin for tile rotation and flipping.

There's no need for a new SDK download - just use the function and it will work in r152+.
Scirra Founder
Posts: 24,433
Reputation: 194,635

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest