Jump to content

[AYUDA] Imagen POS


Mixters

Recommended Posts

Double Hell No!

Lo bueno de los GUI es poseer la propiedad de relative, me explico.

guiCreateStaticImage(0.25, 0.25, 0.75, 0.75, "imagen", true) 

Utiliza números entre 0 y 1.

Ejem: Si mi pantalla es 800x600, X = 1 = 800, Y = 1 = 600.

Pon el ultimo argumento en true y eso lo permitirá en relativa, y utiliza números entre 0 y 1, con el recurso guieditor puedes hacerlo y es mas fácil.

Link to comment
Double Hell No!

Lo bueno de los GUI es poseer la propiedad de relative, me explico.

guiCreateStaticImage(0.25, 0.25, 0.75, 0.75, "imagen", true) 

Utiliza números entre 0 y 1.

Ejem: Si mi pantalla es 800x600, X = 1 = 800, Y = 1 = 600.

Pon el ultimo argumento en true y eso lo permitirá en relativa, y utiliza números entre 0 y 1, con el recurso guieditor puedes hacerlo y es mas fácil.

Triple hell no, recuerda que las PCs de ahora pueden ser widescreen o no widescreen o cuadradas o etc, y puede variar esto

Link to comment
Double Hell No!

Lo bueno de los GUI es poseer la propiedad de relative, me explico.

guiCreateStaticImage(0.25, 0.25, 0.75, 0.75, "imagen", true) 

Utiliza números entre 0 y 1.

Ejem: Si mi pantalla es 800x600, X = 1 = 800, Y = 1 = 600.

Pon el ultimo argumento en true y eso lo permitirá en relativa, y utiliza números entre 0 y 1, con el recurso guieditor puedes hacerlo y es mas fácil.

Triple hell no, recuerda que las PCs de ahora pueden ser widescreen o no widescreen o cuadradas o etc, y puede variar esto

Si se, pero es mas útil así, jamas he visto problemas con esto (no tan notorios) y es mas fácil que explicarle como poner una imagen en un espacio mas especifico con tu técnica.

Pero si quisiera hacerlo como tu, usaría:

local w, h = guiGetScreenSize() 
local x, y = 200, 500 -- pixels de la imagen 
guiCreateStaticImage(w*.5 - x*.5, h*.5 - y*.5, x, y, "imagen", false) 

La multiplicación es mas eficiente.

Link to comment
  • 4 weeks later...

@Alexs_Steel

Supongamos que seria con un gif en varias imagenes.

function dxDrawGifImage ( x, y, w, h, path, iStart, iType, effectSpeed ) 
    local gifElement = createElement ( "dx-gif" ) 
    if ( gifElement ) then 
        setElementData ( 
            gifElement, 
            "gifData", 
            { 
                x = x, 
                y = y, 
                w = w, 
                h = h, 
                imgPath = path, 
                startID = iStart, 
                imgID = iStart, 
                imgType = iType, 
                speed = effectSpeed, 
                tick = getTickCount ( ) 
            } 
        ) 
        return gifElement 
    else 
        return false 
    end 
end 
  
addEventHandler ( "onClientRender", root, 
    function ( ) 
        local currentTick = getTickCount ( ) 
        for index, gif in ipairs ( getElementsByType ( "dx-gif" ) ) do 
            local gifData = getElementData ( gif, "gifData" ) 
            if ( gifData ) then 
                if ( currentTick - gifData.tick >= gifData.speed ) then 
                    gifData.tick = currentTick 
                    gifData.imgID = ( gifData.imgID + 1 ) 
                    if ( fileExists ( gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType ) ) then 
                        gifData.imgID = gifData.imgID 
                        setElementData ( gif, "gifData", gifData ) 
                    else 
                        gifData.imgID = gifData.startID 
                        setElementData ( gif, "gifData", gifData ) 
                    end 
                end 
                dxDrawImage ( gifData.x, gifData.y, gifData.w, gifData.h, gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType ) 
            end 
        end 
    end 
) 
  
gif = dxDrawGifImage ( 1014, 677, 261, 42, "images/img", 0, "png", 160 ) 
gif = dxDrawGifImage ( 1014, 677, 261, 42, "images/img", 1, "png", 160 ) 
gif = dxDrawGifImage ( 1014, 677, 261, 42, "images/img", 2, "png", 160 ) 
gif = dxDrawGifImage ( 1014, 677, 261, 42, "images/img", 3, "png", 160 ) 

¿que puedo hacer?

quiero que las imagenes mantengan una posicion en todas las resoluciones, pero mi problema es que no me funcionaron sus ejemplos :S

Link to comment
@Alexs_Steel

Supongamos que seria con un gif en varias imagenes.

function dxDrawGifImage ( x, y, w, h, path, iStart, iType, effectSpeed ) 
    local gifElement = createElement ( "dx-gif" ) 
    if ( gifElement ) then 
        setElementData ( 
            gifElement, 
            "gifData", 
            { 
                x = x, 
                y = y, 
                w = w, 
                h = h, 
                imgPath = path, 
                startID = iStart, 
                imgID = iStart, 
                imgType = iType, 
                speed = effectSpeed, 
                tick = getTickCount ( ) 
            } 
        ) 
        return gifElement 
    else 
        return false 
    end 
end 
  
addEventHandler ( "onClientRender", root, 
    function ( ) 
        local currentTick = getTickCount ( ) 
        for index, gif in ipairs ( getElementsByType ( "dx-gif" ) ) do 
            local gifData = getElementData ( gif, "gifData" ) 
            if ( gifData ) then 
                if ( currentTick - gifData.tick >= gifData.speed ) then 
                    gifData.tick = currentTick 
                    gifData.imgID = ( gifData.imgID + 1 ) 
                    if ( fileExists ( gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType ) ) then 
                        gifData.imgID = gifData.imgID 
                        setElementData ( gif, "gifData", gifData ) 
                    else 
                        gifData.imgID = gifData.startID 
                        setElementData ( gif, "gifData", gifData ) 
                    end 
                end 
                dxDrawImage ( gifData.x, gifData.y, gifData.w, gifData.h, gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType ) 
            end 
        end 
    end 
) 
  
gif = dxDrawGifImage ( 1014, 677, 261, 42, "images/img", 0, "png", 160 ) 
gif = dxDrawGifImage ( 1014, 677, 261, 42, "images/img", 1, "png", 160 ) 
gif = dxDrawGifImage ( 1014, 677, 261, 42, "images/img", 2, "png", 160 ) 
gif = dxDrawGifImage ( 1014, 677, 261, 42, "images/img", 3, "png", 160 ) 

¿que puedo hacer?

quiero que las imagenes mantengan una posicion en todas las resoluciones, pero mi problema es que no me funcionaron sus ejemplos :S

local sWidth,sHeight = guiGetScreenSize() 
  
function dxDrawGifImage ( x, y, w, h, path, iStart, iType, effectSpeed ) 
    local gifElement = createElement ( "dx-gif" ) 
    if ( gifElement ) then 
        setElementData ( 
            gifElement, 
            "gifData", 
            { 
                x = x, 
                y = y, 
                w = w, 
                h = h, 
                imgPath = path, 
                startID = iStart, 
                imgID = iStart, 
                imgType = iType, 
                speed = effectSpeed, 
                tick = getTickCount ( ) 
            } 
        ) 
        return gifElement 
    else 
        return false 
    end 
end 
  
addEventHandler ( "onClientRender", root, 
    function ( ) 
        local currentTick = getTickCount ( ) 
        for index, gif in ipairs ( getElementsByType ( "dx-gif" ) ) do 
            local gifData = getElementData ( gif, "gifData" ) 
            if ( gifData ) then 
                if ( currentTick - gifData.tick >= gifData.speed ) then 
                    gifData.tick = currentTick 
                    gifData.imgID = ( gifData.imgID + 1 ) 
                    if ( fileExists ( gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType ) ) then 
                        gifData.imgID = gifData.imgID 
                        setElementData ( gif, "gifData", gifData ) 
                    else 
                        gifData.imgID = gifData.startID 
                        setElementData ( gif, "gifData", gifData ) 
                    end 
                end 
                dxDrawImage ( gifData.x, gifData.y, gifData.w, gifData.h, gifData.imgPath .."".. gifData.imgID ..".".. gifData.imgType ) 
            end 
        end 
    end 
) 
  
gif = dxDrawGifImage ( (1014/1366)*sWidth, (677/768)*sHeight, (261/1366)*sWidth, (42/768)*sHeight, "images/img", 0, "png", 160 ) 
gif = dxDrawGifImage ( (1014/1366)*sWidth, (677/768)*sHeight, (261/1366)*sWidth, (42/768)*sHeight, "images/img", 1, "png", 160 ) 
gif = dxDrawGifImage ( (1014/1366)*sWidth, (677/768)*sHeight, (261/1366)*sWidth, (42/768)*sHeight, "images/img", 2, "png", 160 ) 
gif = dxDrawGifImage ( (1014/1366)*sWidth, (677/768)*sHeight, (261/1366)*sWidth, (42/768)*sHeight, "images/img", 3, "png", 160 ) 

donde ponga (..../1366) cambias el 1366 y el 768 por la resolucion de la pantalla en la que creaste el dx

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...