Szerző Téma: hud mozgatás  (Megtekintve 3995 alkalommal)

hud mozgatás
« Dátum: 2017. Április 10. - 22:53:29 »
0
Sziasztok!
 
Nem rég scriptelek, csupán csak 2 napja, ezért előre elnézést ha hülyeséget írok le/kérdezek.
 
Nos szeretnék egy olyat csinálni, hogy van egy dxDrawText-em, ami az óra jelen esetben. Kurzor-t behozom Mbetűvel, és ha rákattintok a kurzoromnak a pozícióján lesz állandóan az óra, amíg el nem engedem. Ezt hogy oldahatom meg?
 
Próbálgattam, de ssak a jobb felső sarokban van az óra ha előhozom a kurzort. 
 
\"help1.png\"
 
 
 
Idáig juttottam el:
 


function cursor ()
    showCursor(not isCursorShowing())
end
bindKey (\"m\", \"down\", cursor)
addCommandHandler ( \"cursor\", cursor )

local x,y = guiGetScreenSize()
oX, oY = 1280, 768
function hud ()
    local time = getRealTime()
    local cursorX, cursorY = getCursorPosition()
    
    dxDrawText (time.hour .. \":\" .. time.minute, cursorX, cursorY, _, _, 0xcff00ff00, 2.1/oX*x, \"pricedown\", \"left\", \"top\")
end
addEventHandler (\"onClientRender\", root, hud)

Nem elérhető Enigma

  • 391
    • Profil megtekintése
hud mozgatás
« Válasz #1 Dátum: 2017. Április 10. - 23:37:48 »
+1
kurzor poziciókat szorozd meg a képernyőmérettel.
 
cursorX * x
 
cursorY * y
 
akkor kapsz majd egy rendes képernyőméretet, így mostmár követni fogja a kurzort.

hud mozgatás
« Válasz #2 Dátum: 2017. Április 11. - 00:05:48 »
0
Köszi szépen. Esetleg azt tudja még valaki hogy hogyan tudom megoldani hogy csak akkor kövesse ha ràkattintok? És hogy ott mentse le ahova hùzom?

hud mozgatás
« Válasz #3 Dátum: 2017. Április 11. - 00:11:53 »
0
Nem tudok magyarázni, a menet ugyanaz.
 

local screenW, screenH = guiGetScreenSize()
local rectangleW, rectangleH =  300, 200
local rectangleX, rectangleY = screenW/2 - rectangleW/2, screenH/2 - rectangleH/2
local rectangleMovingOffsetX, rectangleMovingOffsetY = 0, 0
local rectangleIsMoving = false
addEventHandler(\"onClientRender\", root, function()
dxDrawRectangle(rectangleX, rectangleY, rectangleW, rectangleH, tocolor(0, 0, 0, 150))
end)
addEventHandler(\"onClientKey\", root, function(button, state)
if button == \"m\" and state then
   showCursor(not isCursorShowing())
end
end)
addEventHandler(\"onClientClick\", root, function(button, state, cursorX, cursorY)
if button == \"left\" and state == \"down\" then
   if isCursorInPosition(rectangleX, rectangleY, rectangleW, rectangleH) then
      rectangleIsMoving = true
      rectangleMovingOffsetX, rectangleMovingOffsetY = cursorX - rectangleX, cursorY - rectangleY
   end
else
   rectangleIsMoving = false
end
end)
addEventHandler(\"onClientCursorMove\", root, function(_, _, absoluteX, absoluteY)
if rectangleIsMoving then
   rectangleX, rectangleY = absoluteX - rectangleMovingOffsetX, absoluteY - rectangleMovingOffsetY
end
end)
function isCursorInPosition(rectX, rectY, rectW, rectH)
local cursorX, cursorY = getCursorPosition()
cursorX, cursorY = cursorX * screenW, cursorY * screenH
return (cursorX >= rectX and cursorX <= rectX+rectW) and (cursorY >= rectY and cursorY <= rectY+rectH)
end

 
 
« Utoljára szerkesztve: 2017. Április 17. - 19:04:01 írta impreZZa »

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal