Nitro187's Recent Forum Activity

  • What I'm trying to do is capture the output from a webcam, to this canvas plugin - so I can use it as an object..... problem is, the webcam plugin I'm using (different than the built in c2 one. It's proprietary) pretty much copies the output of the webcam directly to the c2 canvas... the only way it can be done.... the problem with this particular plugin however, is that it only pastes from a specified layer... and not "all layers" or "entire canvas".

    Is there some way I could edit the canvas's "PasteLayer" part of the plugin, in order to capture all the layers, or the entire c2canvas, wherever the canvas instance is? Perhaps add a new function "PasteCanvas" ?

    If i'm not being clear enough, let me know.

    Thanks!

  • Hey R0J0hound,

    I've modified your plugin to my liking, and was curious if you'd like to include it in your code going forward? Here's what I did:

    In EditTime.js

    AddNumberParam("X pos", "The X pos to paste from.");
    AddNumberParam("Y pos", "The Y pos to paste from.");
    AddNumberParam("Width", "The Width of Section to paste from.");
    AddNumberParam("Height", "The Height of Section to paste from.");
    AddAction(23, 0, "Paste Section", "Canvas", "Paste Section Coordinate x: {0}, y: {1}, width: {2}, height: {3} onto canvas", "Pastes Section into the canvas.", "PasteSection");
    [/code:oo4tpvca]
    
    In Runtime.js
    [code:oo4tpvca]	acts.PasteSection = function (x,y,w,h)
    	{
    		var ctx=this.ctx;
    		var buffer = document.getElementById('c2canvas');
    		var bufferCtx = buffer.getContext("2d");
    		var bufferTMP = document.createElement('canvas');		
    		var bufferTMPCtx = bufferTMP.getContext("2d");
    		var myImageData = bufferCtx.getImageData(x, y, w, h);
    		bufferTMP.width = w;
    		bufferTMP.height = h;
    		bufferTMPCtx.putImageData(myImageData, 0, 0);
    		ctx.drawImage(bufferTMP,0,0,this.width,this.height);
    		this.runtime.redraw = true;
            this.update_tex = true;
    	};[/code:oo4tpvca]
    
    I'm sure there may be a better way of doing this... but this is the method that worked for me.  The good thing about this code is, it takes ALL of the layers at the exact point you specify in the C2Canvas.  Great for lots of uses, including mine.  Works great too.  If you're not interested in including it, that's ok... I'll just modify yours every time I need to download it. 
    
    Hopefully other people are able to get a use out of this too.
  • That will only draw on the canvas that the canvas plugin you inserted created for you. I want to be able to draw something on the main Construct2 canvas. Mainly cause my plugin cannot have more than one instance... and this method would force that.

    I also looked inside the canvas plugin, and couldn't find a way to make it draw to the main c2 canvas.... this one will only draw on it's own instance.

  • I'm trying to draw a box directly to the C2 canvas from a plugin... how do I do this?

    I tried the following... but perhaps I'm missing something:

    var c = document.getElementById("c2canvas");
    var ctx = c.getContext("2d");
    ctx.fillStyle = "#FF0000";
    ctx.fillRect(0,0,150,75);[/code:39p9qx1t]
    
     It gives me the error: cannot set property "fillstyle" of null
    
    This exact code works fine in any other javascript... so I'm confused.  I know I have the right canvas name (c2canvas).  Any help?
    
    Perhaps I'm going about this the wrong way... what I want to do, is have only one instance of my plugin, but be able to draw images, and other drawings directly to the canvas at any time, so I'm not limited to just one picture on one layout.  I hope I'm making sense.  The easiest help you could give me I guess, is how can I make that code above work inside a plugin?
    
    Thanks!
  • Awesome.... figures I would have missed that one. Thanks!

    With that, I also figured out how to change the position too:

    Set X- CanvasToLayerX("Layer 0",LayerToCanvasX("Layer 1", sprite2.X, sprite2.Y) ,LayerToCanvasY("Layer 1", sprite2.X, sprite2.Y))

    Set Y- CanvasToLayerY("Layer 0",LayerToCanvasX("Layer 1", sprite2.X, sprite2.Y) ,LayerToCanvasY("Layer 1", sprite2.X, sprite2.Y))

    Thanks again!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I have an object that's somewhere outside of my project.... I would like to track it's X&Y exactly, however because it has a different parallax than the 'arrow' i'm using to point at the object, the arrow reads a different X & Y coordinate, showing it off. When it's not zoomed in... it's fine. When you zoom in (layout scale) it screws up, because of the parallax.

    Can anyone help me out? It's 5 in the morning... I've been up all night... probably the reason I'm not figuring this out.... also the reason this may not make any sense to anyone... hence the upload.

    [attachment=0:3kvi0yrc][/attachment:3kvi0yrc]

    Thanks!

  • I don't know... some guy made a "tilesprite" plugin, and abandoned it... so I figured I would make my own version.

  • In case anyone is interested.... I started my own take on this type of plugin.:

  • I've been working on a new version of an old abandoned plugin... and figured I could use some of everyone's help in getting it working perfectly.

    Basically, this makes a Tiled image act like a sprite, with animations and what not.

    It currently only works in non-WebGL mode.... cause I don't know how to fully get it to work in GL. I'm working on it.... but for now, it's non-WebGL only. For some reason, however, it works in both GL & Non-GL in the preview window.

    Thoughts? Help?

    Bugs: -

      Critical: For some reason, it has a major memory leak... and I haven't looked into why just yet. You can see in the demo above as to what I'm referring to. after about 5 -10 seconds, the FPS start dropping.... most likely due to the fact it's leaking memory, but I'm not entirely sure. This only seems to happen on large sprites, and not tiny ones. Any thoughts?
      Does not work in WebGL mode
      Causes a crash in Construct2 every once in a while in regards to textures not being in memory. Only appears to happen when opening the editor and closing without making a change.

    Plugin: http://www.nitrolic.com/water/tiledsprite.c2addon

    Demo CAPX: http://www.nitrolic.com/water/demo.capx

    Demo URL: http://www.nitrolic.com/water

    Enjoy guys.

  • Problem Description

    32bit gif won't import into sprite object

    Files to test with:

    http://www.nitrolic.com/water.gif

    http://www.nitrolic.com/water2.gif

    Steps to Reproduce Bug

    • Import the file water.gif (32bit), from the "import from files" option.
    • Import the water2.gif (8bit) from the "Import from files" option.

    Observed Result

    The water.gif will NOT load, but the water2 WILL.

    Expected Result

    Both should open.

    Operating System and Service Pack

    Windows 7 64bit SP1

    Construct 2 Version ID

    188

  • I did not know C2 had PI.... thanks man.

  • Thanks - worked like a charm.

Nitro187's avatar

Nitro187

Member since 26 Jan, 2014

None one is following Nitro187 yet!

Trophy Case

  • 10-Year Club
  • Email Verified

Progress

11/44
How to earn trophies