kmsravindra
Found this:
http://stackoverflow.com/questions/1257 ... d-polyline
It proved simple enough:
https://dl.dropboxusercontent.com/u/542 ... ezier.capx
R0J0hound, you are absolutely brilliant...Thanks a lot for this working example.
MrShortee Good to know. Fixed.
MrShortee
Good to know. Fixed.
Awesome, thank you!
R0J0hound
Canvas plugin might not work correctly when official load, no image loaded back. -- test capx
(environment: C2-r222, window7 32bit, chrome browser)
BTW, it might improve performance that loading image data by putImageData method.
I had made a behavior to help user tests pixel overlapping between sprite and canvas easily.
Demo
Is there a c2addon format anywhere cuz,i cant install this for some reason
—: Drag it into Construct2 when it's open. It'll ask you to install it. Cheers!
These code could fix the bug of loading.
// called when loading the full state of the game instanceProto.loadFromJSON = function (o) { var canvasWidth = this.canvas.width = o["canvas_w"]; var canvasHeight = this.canvas.height = o["canvas_h"]; var img_data = this.ctx.createImageData(canvasWidth, canvasHeight); var data = img_data.data; var cnt = data.length; for(var i=0; i<=cnt; i++) data[i] =o["image"][i]; this.ctx.putImageData(img_data, 0, 0); };[/code:31ka48yz]
Which bug?
Nitro187
Loading by official load action.
rexrainbow: Works great - you mentioned that "putImageData" has better performance... is this just for the loadFromJSON, or would this also increase performance for PasteLayer? Cause I'm noticing a lot of CPU usage when using it... especially on every tick.
Develop games in your browser. Powerful, performant & highly capable.
Here is the origin code of loading, ( downloaded in 1st post )
// called when loading the full state of the game instanceProto.loadFromJSON = function (o) { var canvasWidth = this.canvas.width = o["canvas_w"]; var canvasHeight = this.canvas.height = o["canvas_h"]; var data = this.ctx.getImageData(0,0,this.canvas.width,this.canvas.height).data; for (var y = 0; y < canvasHeight; ++y) { for (var x = 0; x < canvasWidth; ++x) { var index = (y * canvasWidth + x)*4; for (var c = 0; c < 4; ++c) data[index+c] = o["image"][index+c]; } } // load from the state previously saved by saveToJSON // 'o' provides the same object that you saved, e.g. // this.myValue = o["myValue"]; // note you MUST use double-quote syntax (e.g. o["property"]) to prevent // Closure Compiler renaming and breaking the save format };[/code:26psdbe6] "ctx.getImageData" only copy image data, not get the reference. Any modification of this data array would not affect the canvas image. [code:26psdbe6]var data = this.ctx.getImageData(0,0,this.canvas.width,this.canvas.height).data;[/code:26psdbe6] The solution of change the image of this canvas is using "ctx.putImageData", imo. Since this method needs an image data parameter, I use "ctx.createImageData" to create a new one, then fill it by saving data. Finally put this new image data back by "ctx.putImageData",
rexrainbow: Ahh, gotcha. Thanks.
TheWyrm Somebody I had made a behavior rex_canvasext to load image in rojo's canvas plugin.
TheWyrm
Somebody
I had made a behavior rex_canvasext to load image in rojo's canvas plugin.
Not working for me =(
Irbis
That message is usually because you have placed a 'Behavior' in the 'Plugins' folder.