How do I import existing canvas of animated logo in C2?

Get help using Construct 2

Post » Thu Oct 23, 2014 7:35 am

I'm just wondering, there an existing script to import logo which is programmed with pure javascript.

Is possible to import this canvas in C2?
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Fri Oct 24, 2014 9:10 am

@r0j0hound

Hello, do you think it's possible to import external canvas with your canvas plugin?
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Fri Oct 24, 2014 8:03 pm

Not with the canvas plugin, it wasn't designed for it. It can be done if you wish to delve into the plugin sdk.

With webgl off html5 canvases are as easy to draw as any other image so the main thing you'd need to change in a plugin is the draw() function to basically this:
Code: Select all
instanceProto.draw = function(ctx)
{
ctx.save();
ctx.rotate(this.angle);
ctx.drawImage(document.getElementById("myCanvas"),
      0 - (this.hotspotX * this.width),
      0 - (this.hotspotY * this.height),
      this.width,
      this.height);
ctx.restore();
};

Where "myCanvas" is the id of the canvas you want to draw in C2. It has to exist somewhere on the webpage.

Making it work with webgl "on" requires converting the canvas to a webgl texture every time and that's not exactly a fast operation. You can reference my canvas plugin to see one way to do it.
B
94
S
33
G
118
Posts: 5,394
Reputation: 75,849

Post » Sat Oct 25, 2014 3:25 am

@R0J0hound Thanks!

I will see I can do with your snippet, I hope it would work.
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421


Return to How do I....?

Who is online

Users browsing this forum: RIDETHEPIG and 9 guests