Space Monkey

This topic contains 3 replies, has 3 voices, and was last updated by  SekaiChi 5 months, 2 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #14092

    PhatPeter
    Participant

    Taking a pause from other programming to do some Monkey2. Great fun so far !
    Making a simple space shootem’up and now I want to try out and use gestures for finding star systems that you need to go to.

    I found a great banana example but it seems to have strange behaviour when you release the fingers it bounces back 🙁

    #14099

    Pakz
    Participant

    I have not done any touch things yet but I noticed you use touchdown. Is there no touchup or release? I would. Look at that.

    #14100

    PhatPeter
    Participant

    No it’s not about finger up and down because I can do this to save the position (but it does not anything but a black screen if your device have no multitouch of course now).

    It’s all about making the touch movement relative, you need to be able to “remember” the last position so to speak and “add” each additional movement and this works by using matrixes and I know nothing about matrixes?

    #14259

    SekaiChi
    Participant

    One can use this general formula 🙂

    ‘ Rotation
    var startVector = point#0.start – point#1.start
    var currentVector = point#0.current – point#1.current
    var startAngle = math.atan2( startVector.Y, startVector.X )
    var endAngle = math.atan2( currentVector.Y, currentVector.X )
    var deltaAngle = endAngle – startAngle

    ‘ Panning
    var startCenter = (point#0.start – point#1.start)/2 + point#1.start
    var currentCenter = (point#0.current – point#1.current)/2 + point#1.current
    var rawTrans = currentCenter – startCenter
    ‘ Now add rotation to rawtrans and call it translation
    var rotationMatrix = matrix.rotationZ(-angle)
    var translation = vector.transform(rawTrans, rotationMatrix)

    ‘ Zooming
    var startVector = point#0.start – point#1.start
    var currentVector = point#0.current – point#1.current
    var scale = vector.length(currentVector) / vector.length(startVector)
    var translation = vector.transform(rawTrans, rotationMatrix) / scale

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.