Jump to content

Problema con una animacion (SpriteAnim)


Bc#

Recommended Posts

Posted
Cuando usas DirectX, tenes que usar posiciones en "absolute".

Una posicion absolute seria asi: 500, 500, 100, 200

Una en relative seria algo asi: 0.05, 0.8, 0.65, 0.15

Eh probado muchas posisiones y multiples tamaños y aun no consigo nada.

function dxDrawGifImage ( x, y, w, h, path, iEnd, effectSpeed ) 
            local gifElement = createElement ( "dx-gif" ) 
            if ( gifElement ) then 
                setElementData ( 
                    gifElement, 
                    "gifData", 
                    { 
                        x = x, 
                        y = y, 
                        w = w, 
                        h = h, 
                        imgPath = path, 
                        endID = iEnd, 
                        imgID = 1, 
                        speed = effectSpeed, 
                        tick = getTickCount ( ) 
                    } 
                ) 
                return gifElement 
            else 
                return false 
            end 
        end 
          
        addEventHandler ( "onClientRender", root, 
            function ( ) 
                local currentTick = getTickCount ( ) 
                for _, 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 gifData.imgID > gifData.endID then 
                                gifData.imgID = 1 
                            end 
                            setElementData ( gif, "gifData", gifData ) 
                        end 
                        dxDrawImage ( gifData.x, gifData.y, gifData.w, gifData.h, string.format(gifData.imgPath,gifData.imgID) ) 
                    end 
                end 
            end 
        ) 
          
   gif = dxDrawGifImage ( 769, 175, 193, 145, "img/logo", 13, "png", 60 ) 

Si puedes ves estoy usando la misma posision que sugeriste en el wiki, pero nisiquiera haci logra aparecer alguna imagen.

Posted

http://www.mediafire.com/?eovb4xcdw3xbhvt

Ahi esta.

Ahora ultimo estube probando algo, con este script pude proyectar la primera imagen en el servidor pero la animacion es lo que me complica.

local sWidth,sHeight = guiGetScreenSize() 
    gif = dxDrawGifImage (sWidth*0.75,sHeight*-0.03,sWidth*0.3,sHeight*0.3, "img/logo1.png", 20, 120 ) 

Posted

Lo que paso es que alguien modifico mi funcion ( dxDrawGifImage ) y la modifico mal, porque ya no funciona.

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 ( 769, 175, 193, 145, "img/logo", 1, "png", 60 ) 

Funca perfecto.

Posted
Lo que paso es que alguien modifico mi funcion ( dxDrawGifImage ) y la modifico mal, porque ya no funciona.
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 ( 769, 175, 193, 145, "img/logo", 1, "png", 60 ) 

Funca perfecto.

¿Seguro que ese es el script?

Yo lo probe y nada.

Posted
Ese que poste es el que yo use y funciono.

Capaz que no aparece en tu resolucion, yo uso 1024 * 768.

Si ese era el problema funciona perfect muchas grasias C:

Posted

intente hacer el mio, tome posiciones de una imagen de test, pero no aparece el gif D:

  
        function dxDrawGifImage ( x, y, w, h, path, iEnd, effectSpeed ) 
            local gifElement = createElement ( "dx-gif" ) 
            if ( gifElement ) then 
                setElementData ( 
                    gifElement, 
                    "gifData", 
                    { 
                        x = x, 
                        y = y, 
                        w = w, 
                        h = h, 
                        imgPath = path, 
                        endID = iEnd, 
                        imgID = 1, 
                        speed = effectSpeed, 
                        tick = getTickCount ( ) 
                    } 
                ) 
                return gifElement 
            else 
                return false 
            end 
        end 
          
        addEventHandler ( "onClientRender", root, 
            function ( ) 
                local currentTick = getTickCount ( ) 
                for _, 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 gifData.imgID > gifData.endID then 
                                gifData.imgID = 1 
                            end 
                            setElementData ( gif, "gifData", gifData ) 
                        end 
                        dxDrawImage ( gifData.x, gifData.y, gifData.w, gifData.h, string.format(gifData.imgPath,gifData.imgID) ) 
                    end 
                end 
            end 
        ) 
          
   gif = dxDrawGifImage ( 504, 29, 105, 75, "img/logo", 33, "png", 60 ) 
  

Posted
aparece pero se queda en la primera imagen D:

Podrías probar con esto.

   gif = dxDrawGifImage ( 504, 29, 105, 75, "img/logo", 1, "png", 120 ) 

No estoy seguro pero el argumento que tenias en 33 debe estar en 1 o 0 dependiendo de el numero con el que comiese la primera imagen del ciclo.

ejemplo:

si tu primera imagen es logo0 usas:

   gif = dxDrawGifImage ( 504, 29, 105, 75, "img/logo", 0, "png", 120 ) 

y si es logo1 usas:

   gif = dxDrawGifImage ( 504, 29, 105, 75, "img/logo", 0, "png", 120 ) 

y por experiencia propia yo recomiendo usar 120 en el argumento de effectspeed por que sino va muy rápido el gif y no da tiempo de verlo.

PD: Si quieres que funcione usa la funcion del wiki.

  • Recently Browsing   0 members

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