[PLUGIN] Canvas

Post your completed addons to share with the community

Post » Tue Dec 17, 2013 1:59 am

Opps, that post I quoted was wrong. Just fixed it. For your capx the correct equation would be:

Array.At(0, 0, (int(mouse.y)*Canvas.Width + int(mouse.x))*4 + 0)

It would be more intuitive like you said, but I was going for it being as fast as possible when I did it and haven't gotten around to a correct fix.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Tue Dec 17, 2013 4:07 am

Awesome, it works perfectly now. Thanks!
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Thu Dec 19, 2013 6:37 am

Hey I really like your plugin and am curious if it's possible to make it so that a line will stop drawing when you hit or intersect a specified object. So let's say I had the player, an enemy, and a wall. I want to make it so that a line will be drawn between the player and the enemy, but the line will immediately end when it hits the wall. So if the wall is between the two, the line will stop drawing at the wall. Do you know of any way I can do this?

Any help would be appreciated.
B
5
Posts: 19
Reputation: 713

Post » Thu Dec 19, 2013 6:14 pm

That's solvable completely without the canvas plugin. Search for "laser" and you should find a few examples of making a laser that stops when hitting another object.

Here's one:
http://www.scirra.com/forum/laser-collision-point_topic44892.html, there are others.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Sat Dec 28, 2013 8:00 pm

is there a how to or any documentation on how to use this?
Sorry if im missing something
B
22
S
6
G
1
Posts: 269
Reputation: 2,572

Post » Sun Dec 29, 2013 6:28 am

I don't have any documentation, this topic is a good place to get info on how to use it though. The plugin's actions are fairly self explanatory and there are examples in this topic that show it's use in various situations.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Thu Jan 09, 2014 12:22 pm

I changed a function in the plugin to be able to paste tiledbg in webGL mode.
In canvas2D mode, the tiledbg generate a pattern, but not in webGL, so the region pasted ends up black

here is the fix:
[code]    //helper function
    instanceProto.draw_instances = function (instances, ctx)
    {
        for(var x in instances)
        {
            if(instances[x].visible==false && this.runtime.testOverlap(this, instances[x])== false)
               continue;
            
            ctx.save();
            ctx.scale(this.canvas.width/this.width, this.canvas.height/this.height);
            ctx.rotate(-this.angle);
            ctx.translate(-this.bquad.tlx, -this.bquad.tly);
            ctx.globalCompositeOperation = instances[x].compositeOp;//rojo

            if (instances[x].type.pattern !== undefined && instances[x].type.texture_img !== undefined) {
               instances[x].pattern = ctx.createPattern(instances[x].type.texture_img, "repeat");              
            }

            instances[x].draw(ctx);
            ctx.restore();
        }
    };[/code]Yann2014-01-09 12:23:25
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat Jan 25, 2014 1:52 am

Hi, how do I make the canvas object follow the player?
B
38
S
8
G
3
Posts: 438
Reputation: 6,869

Post » Sat Jan 25, 2014 2:39 am

Pinning works.
ImageImageImage
B
67
S
19
G
121
Posts: 3,196
Reputation: 72,879

Post » Sat Jan 25, 2014 3:15 am

https://dl.dropboxusercontent.com/u/6813637/s_/index.html
Ive pinned the canvas objects to the player, but the light got all wrong.
I want te canvas to aways be on the screen rendering the lights/shadows, to save processing power. ;]
My project is here, Im making a game for GGJ, any help would be much appreciated ^^
https://dl.dropboxusercontent.com/u/6813637/light_test.capx
B
38
S
8
G
3
Posts: 438
Reputation: 6,869

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 5 guests