I want to draw in canvas when layout is rotated at 270 degree angle, How to translate touch position

0 favourites
  • 7 posts
From the Asset Store
270 Orchestral Soundtracks + 65 Ambient Soundscapes | 7 HOURS of Audio | 335 Clips in Total
  • I have layout and canvas inside. I'm drawing in canvas using brush sprite. I have requirement to rotate layout at 270 degree and now drawing in canvas has issue because of coordinate. how to I translate touch coordinates for rotated layout?

  • In general construct will handle that for you. By default I think that touch.x will get the position on the top layer but you can specify the layer with touch.x(layer)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • R0J0hound see my events and you'll see what issue I'm facing.

    layout is rotated at 270 degree So my input from mouse also being rotated. So if I drag my mouse top to bottom in canvas drawing from right to left.

    myfile

  • Maybe just add a hud layer that you don’t rotate? Again construct should do the conversions for you.

    Alternately if you just want to do the conversions your self here is the formula to rotate a position around a point. Maybe you can use that to unrotate the touch position or something.

    NewX=(x-centerX)*cos(a)-(y-centerY)*sin(a)+centerX

    NewY=(x-centerX)*sin(a)+(y-centerY)*cos(a)+centerY

  • R0J0hound I tried both ways apply HUD and formula. I was able to fill only upto certain area and both ways has same result.

    is there any way to paste object at a position. there is no option in actions but can we do this through Javascript?

  • I tried opening it. No new ideas. Maybe rotate the layer instead of the layout? I ran out of time to fiddle with it. JavaScript won’t provide anything more than what you can do with events.

    I won’t be able to debug it. If the sprite isn’t being drawn where you touch then construct isn’t doing what it should or we just aren’t understanding what is happening. I gave the rotation formula to give a way to correct it. With 90 degree turns the coordinates come out to either

    -touch.y+2*scrollx, touch.x

    Touch.y, -touch.x+2*scrolly

    If it’s not drawing the whole area then check the drawing canvas size.

    If none of that works or doesn’t makes sense then I’m explaining it poorly or missing something.

    Probably best to wait for someone else’s answer at that point.

  • Maybe this is a bug. I created bug report on this. and same bug was created year ago by someone where Ashley Assigned himself but not resolved yet.

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