gbataille's Recent Forum Activity

  • Well seems it's working on IPhone 4 but not on 5.

    Here's the bug on IPhone 5:

    <img src="http://consultationmagaliederouin.com/iphone.jpg" border="0" />

    Have you ever seen this problem?

  • Delete circle done:

    Acts.prototype.DeleteCircle = function (x,y,radius)

         {

              var centerX=x;

              var centerY=y;

              var squareRadius = radius * radius;

              var ctx = this.ctx;

              var imageData= ctx.getImageData(centerX-radius,centerY-radius,radius+radius,radius+radius);

              var pos=0;

              for (y = -radius; y <= radius; y++)

                  for (x = -radius; x <= radius; x++)

                   {     

                        var total = (x * x) + (y * y);

                       if (total <= squareRadius)

                        {

                             imageData.data[pos] = 0;     // R

                             imageData.data[pos+1] = 0;     // G

                             imageData.data[pos+2] = 0;     // B

                             imageData.data[pos+3] = 0;     // A     

                        }

                        pos+=4;

                   }

                   

              ctx.putImageData(imageData,centerX-radius,centerY-radius);

              this.runtime.redraw = true;

            this.update_tex = true;     

         };

    But on IPhone it shows just the BG:

    <img src="http://consultationmagaliederouin.com/TestPNG/testIPhone.jpg" border="0" />

    Any idea on how to make it work on Iphones?

  • Well finally it's easy...

    The alphaAt function does the job:

    exps.alphaAt = function (ret, x, y)

         {

              var imageData= this.ctx.getImageData(x,y,1,1);

              var data= imageData.data;

              ret.set_int(data[3]);

         };

    Or isColliding:

    Cnds.prototype.IsColliding = function (rtype,x,y)

         {

              // Get the drawing context

                   var pixel = this.ctx.getImageData(x, y, 1, 1);

              

                   if (pixel.data[3]>0)

                        return true

                   else

                        return false;

         };

    My test should have a better performance now:

    consultationmagaliederouin.com/TestPNG

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Because this way you get your level in one shoot... No need to take hours to make all platforms...

    This test is a first try. I can surely optimize... Like: maybe it's not nedeed to draw image on the context each time.

    Also I will add a function do delete a part of the image...

    Anyways, any optimizations suggestions are welcome :)

  • Thanks, the code in the Canvas Plugin helped me...

    I have a begining of something:

    consultationmagaliederouin.com/TestPNG/

    But is hardcore because the Platform is not working with my plugin. So I must make all movements myself...

  • Ok, but I think I found another way. I've made an Action "IsColliding(x,y)" to test a pixel.

    Here my function that is not working yet:

    function isPixelCollision( x2, y2 )

    {

       // Create a canvas element

       var canvas = document.getElementById(this.layer);

       // Get the drawing context

       var context = canvas.getContext('2d');

       var pixel = this.runtime.context.getImageData(x2, y2, x2, y2);

       if (pixel.data[3]>0)

         return true

       else

         return false;

    }

    The problem is for accessing the layer. I've put my level on layer 1. Can you tell me a way to do it?

  • I'm trying to do a plugin for .png image with pixel collision.

    But the problem at start is that the player will always collide with my .png level with Solid Behavior.

    The JS code in Behaviors files are only calls to the C++ program and I can't really add a home made behavior?

    Is is possible for Construct conceptors to modify the Solid Behavior to make a "Transparency Behavior" where an object can go through if alpha is zero?

  • Well that's a ingenious hack... So I'll have to make a Image plugin then...

    But I'm new to Construct so can you tell me, where is the data for the tilemap in this project?

    Thanks

  • Yes, to do a game like Worms. The level is a .png and when you shoot on the image, you remove a circle part. I need to access the image data directly at runtime and update the .png.

    I started my game with Unity 3D:

    consultationmagaliederouin.com/soupmouBonneAnnee/

    But I can't make it work on IPhone without paying tons of certificates and licences. So Construct seems a good alternative.

    Here javascript code for per pixel collision:

    playmycode.com/blog/2011/08/javascript-per-pixel-html5-canvas-image-collision-detection/

  • Hi,

    I would like to know if it is planned to implement:

    1. Per pixel collision

    2. Dynamical image data modification

    Thanks

gbataille's avatar

gbataille

Member since 4 Jan, 2014

None one is following gbataille yet!

Trophy Case

  • 10-Year Club
  • Email Verified

Progress

11/44
How to earn trophies