Instance drawing

For developers using the Construct 2 Javascript SDK

Post » Mon Dec 05, 2011 1:02 am

Hi folks.

I'm looking for a way to draw a line which could separated vertically a rectangle.
To sum up, I want to draw a two cells rectangle.
For the moment, I just have one rectangle and I didn't find the good documentation to draw more of one.

Here's my code for now.

IDEInstance.prototype.OnCreate = function()
{
     this.instance.SetHotspot(new cr.vector2(0, 0));
}

IDEInstance.prototype.OnInserted = function()
{
     this.instance.SetSize(new cr.vector2(75, 25));
}
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Tue Dec 06, 2011 1:27 pm

Or some keywords to look for ...?

edit Is it a bug ? My reply send this post to Construct 2 General instead of staying in Construct Engineering...
septeven2011-12-06 13:29:43
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Tue Dec 06, 2011 1:33 pm

Have a look at the Button or TextBox plugins - they draw rectangles in the editor (but don't draw anything at runtime, it's only for the editor draw code). Does that help?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Tue Dec 06, 2011 2:00 pm

Thanks Ashley but it doesn't.
I already drew one rectangle, I just want to know how can insert a vertical line inside this first rectangle.


septeven2011-12-06 14:03:10
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Tue Dec 06, 2011 2:06 pm

It's not a bug I moved it.
Construct Engineering is more about the programming of Construct-Classic.
I was wondering about moving it to the plugins section, as it was where it would be likely to be seen by other developpers, and finaly decided to leave it as general C2 discussion for now.

Have you looked at the manual for the SDK - Edit time ?
It should contain some valuable help.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Tue Dec 06, 2011 3:06 pm

You can also look at my Spritefont plugin, it's got plenty of draws for both canvas and webgl contexes. Though it only draws rectangles in edittime.

Well, you can draw another rectangle, except with width of 1.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Tue Dec 06, 2011 9:57 pm

Thanks to all of you.
I managed to learn more about drawing in the edittime.js.

Nevertheless, I succeed to draw a new rectangle (with new cr.quad()) but impossible to know how to insert this new rectangle directly into my instance.
For now, it's drawn directly at its position in the layout.
Thanks for helping
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Wed Dec 07, 2011 11:32 pm

I would love to find a solution by myself, though I find none documentation about drawing method in js.
I read the sdk and didnt figure out to find an answer to my interrogation.
It's only for aesthetic of my plugin, which is getting close released, but I spent very much time to search and try a solution.
Someone has already drawn a separated rectangle (by drawing two rectangles, or maybe separated two fill color by coordinates, ...)
Thanks
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Mon Jan 23, 2012 2:06 pm

The SDK manual has been updated fairly recently, I believe, so you may want to take a gander at it once again, specifically the edit-time page.

Specifically, you want the renderer.Fill(quad, color). You can create a new quad or use the instance.GetBoundingQuad() to get the instance's quad. You can also use the bounding quad to retrieve instance's corners, angle (calculating it with atan2) and so on.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Tue Feb 07, 2012 12:57 pm

@Ashley I don't think that the question was ever asked, but is it possible to draw other thing than a box and a line, I'm thinking especially to a circle ... ?
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Next

Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests