Auf Cursor-Position zoomen / Zoom to cursor position

  • #1, by thomas-fringsThursday, 25. November 2021, 10:23 2 years ago
    Ist es möglich mit dem Shader-Zoom auf den Mauscursor zu zoomen? Über Lua ist es möglich auf eine Person zu zoomen, aber nicht auf den Cursor. Liege ich damit falsch?

    Is it possible to zoom to the mouse cursor with the shader zoom? Via Lua it is possible to zoom on a person, but not on the cursor.

    Newbie

    21 Posts


  • #2, by SimonSThursday, 25. November 2021, 17:31 2 years ago
    Wenn man das macht muss man einige Randbedingungen abwälzen.
    Aber man kann sich da einfach an der shaderZoomObject orientieren:

    local c_scale = 2.0
    local c_position=getCursorPos()
    local c_scroll=game.ScrollPosition
    c_position.x=c_position.x-c_scroll.x
    c_position.y=c_position.y-c_scroll.y
    c_position.x=c_position.x-(c_res.x/c_scale/2)
    c_position.y=c_position.y-(c_res.y/c_scale/1.2)
    c_position.x = math.min(math.max(0,c_position.x), game.CurrentScene.Sprite:getSize().x - c_res.x/c_scale)
    c_position.y = math.min(math.max(0,c_position.y), game.CurrentScene.Sprite:getSize().y - c_res.y/c_scale)
    shaderViewport(c_scale, c_position.x, c_position.y, 0, 2000, easeQuadInOut)

    Thread Captain

    1580 Posts