tcamacho's Recent Forum Activity

  • Forget it I found the solution use layer.cssPxToLayer(e.clientX, e.clientY); function explained here: construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/layout-interfaces/ilayout/ilayer

    Thanks

  • Hi. What I want is pretty simple. So I have this function running on pointerdown. The thing is that the e.clientX/Y gives me the coordinates for the pointer in the current browser position, and then I get all the polypoints from the obj and then make an array with all the points and send to the tools.inside() function to check if that click is inside that polygon. This works fine if the obj doesn't move. But I have the objects with Anchor behaviour and they move. So what happens is that the polyPoints array is using the coordinates of the obj in the original game resolution (540 x 270). But the pointer uses the window position coordinates with the current resolution from the browser (915 x 412). So when I check if the point is inside the polygon it doesn't match.

    I have tried changing the point position from one resolution but it doesn't work. Is there any function or way to make this work ?

    Thanks

     runtime.addEventListener('pointerdown', (e) => {
     let view = e.runtime.getViewportSize();
     let x = e.clientX - ((window.innerWidth - c3canvas.clientWidth) / 2);
     let y = e.clientY - ((window.innerHeight - c3canvas.clientHeight) / 2); 
     let arr = [];
     
     for (let j = 0; j < obj.getPolyPointCount(); j++){ 
     arr.push([
     ((obj.getPolyPointX(j) * c3canvas.clientWidth) / view[0]),
     ((obj.getPolyPointY(j) * c3canvas.clientHeight) / view[1])
     ]);
     }
     
     if(tools.inside(x,y, arr) && obj.isVisible) {
     this.CallFunction(func);
     } 
     });
    
  • Found my answer if you do

    	c3canvas.width
    	c3canvas.height
    

    You get canvas size which is exactly what I need.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm trying to get the touch position with and i got it this way:

    	r.addEventListener('pointerdown', (e) => {console.log(e.clientX); console.log(e.clientY)});
    
    

    But that doesn't work for what I want. Because those coordinates are relative to the client page, and I need to convert them to the REAL viewport size. What do I mean by real is that my viewport has for example 320x240 standard, but it scales, and I can't find where the size of the viewport is in run time with the current scaling.

    Can anyone point me where I can find it ?

    Thanks :D

  • Hi, I'm working with families and basically families inside families. I was wondering, how much impact disabled behaviors have on performance?

  • Hi, I'm trying to advance minify my project but I can't cause of firebase. This is the code:

    Can anyone help me ?

  • I want to do this but with js.

    This is the type of code that i'm trying to do

    const char = runtime.objects.Character.getFirstInstance();

    char.behaviours.Flash() ???

    setTimeout(() => {

    char.behaviours.Flas.StopFlash();

    }, 300)

  • I found the solution. I was using Platform behaviour with Bullet to move a Top Down player. I Changed it to a custom movement and when it colides with a solid make it push out of a solid but before that set the speed to 0. Worked Perfect!

  • Hi. So i have this object. Where the top polygons have exactly the same points and

    compared wiht bottom ones.

    Then i have the player and this is the polygon:

    My problem is. If the player walks from top to bottom against the edges of that object it gets kinda stuck with friction and works perfect. If the player runs from bottom to top against the edges of the object, it feels like the objects have butter and it just slides away from the object faster then it can actually walk. Why does this happen since the colisions are basically the same ? How can i fix it ? Thank you a lot :D

  • I have found the solution for my problem. I used the the Bullet behaviour to move to some direction, and turn off Bounce of Solid and turn on Step. On overlapping with a solid i said it to bounce off that solid. It worked kinda lagged. But that event was inside a Is in Touch event. I took it out, and works much smoother.

  • Nice, this is a great help for what i want :D thank you

  • I tried that but it looks lagged when it collides, maybe I am doing something wrong.

tcamacho's avatar

tcamacho

Member since 11 May, 2019

None one is following tcamacho yet!

Trophy Case

  • 5-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

7/44
How to earn trophies