Drawing directly to the C2 canvas from plugin

0 favourites
  • 5 posts
From the Asset Store
Pixel Destruction like in "Worms" (Drawing Canvas based)
  • 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";
     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?
  • you could do it like this

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • you could try this tutorial

    https://www.scirra.com/tutorials/258/dr ... onstruct-2

  • If you are writing a plugin and need help, a more appropriate place to post might be in the 'Work in Progress Addons' section.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)