Draw Canvas problem with javascript (plugin)

0 favourites
  • 1 posts
From the Asset Store
Pixel Destruction like in "Worms" (Drawing Canvas based)
  • I really surprised...

    My plugin is worked very well in build r95..

    Problem comes after I attempt to update to r114.

    Javascript library don't recognize the context of element...???

    My code as bellow:

    <font color=RED>

         instanceProto.paint = function (myparam)

         {

          //alert("here: "+ this.runtime.id);      

          //alert(this.x);

          var _x = this.x;

          var _y = this.y;

          var _w = this.width;

          var _h = this.height;

            //this.runtime.trigger(pluginProto.cnds.ImageLoaded,instance);

            var image = new Image();

            image.src = myparam;               

            image.onload= function(){

                var c=document.getElementById("c2canvas");

                var con=c.getContext('2d');

                if(null == con){

                   alert("con is null");

                   return;

                }

                con.drawImage(image, _x - _w/2, _y- _h/2, _w,_h);

            }

               //this.draw(con);

               //this.runtime.redraw=true;

            this.image = image;

           

         };

    </font>

    In test bed, alert message always topup "con is null"...this problem never appeared in old build

    Some one please help me...how to solve this problem

    Thank in advance

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)