Jump to content

Problema con una animacion (SpriteAnim)


Bc#

Recommended Posts

Posted

Trato de hacer una animacion de un logo pero no logro que me funcione este es mi codigo.

  
function logoanimado() 
   SpriteAnim: new( "logo.png", 0.68, 0, 0.45,  0.355, 5, 5, 30); 
end 
  
addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), logoanimado ) 

y esta es la imagen:

logowow.png

me estoy giando a partir de este post:

https://forum.multitheftauto.com/viewtopic.php?f=108&t=49179

Ayuda por favor.

Posted

No entendi mucho lo de la susesion de imagenes

Pero ejemplo este es mi codigo.

  
gif = dxDrawGifImage ( 0.68, 0, 4.5,  3.55, "img/logo%", 0, "png", 60 ) 
  
addCommandHandler ( "destroygif", 
    function ( ) 
        destroyElement ( gif ) 
    end 
) 

asi me tendria que leer las imagenes que en su nombre tengan logo seguido de un numero.

Ejemplo.

logo1, logo2 , logo3, logo4.

Posted
ese es el script de la wiki no es tuyo y esta mas lee mejor ;)

Si se que es de la wiki pero esta adecuado para mi proposito, lo que pregunto se es que funcionaria

Posted

Este script estoy usando.

gif = dxDrawGifImage ( 0.68, 0, 4.5,  3.55, "img/logo%", 13, "png", 60 ) 
  
addCommandHandler ( "destroygif", 
    function ( ) 
        destroyElement ( gif ) 
    end 
) 

pero no se si estara bien el "img/logo%"

Posted
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 ( 0.68, 0, 4.5, 3.55, "img/logo", 13, "png", 60 ) 

Posted
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 ( 0.68, 0, 4.5, 3.55, "img/logo", 13, "png", 60 ) 

Lo probe y no funciona

Posted
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 
) 
  
local sWidth,sHeight = guiGetScreenSize() 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo.png", 20, 120 ) 
  
addCommandHandler ( "destroygif", 
    function ( ) 
        destroyElement ( gif ) 
    end 
) 

Posted
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 
) 
  
local sWidth,sHeight = guiGetScreenSize() 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo.png", 20, 120 ) 
  
addCommandHandler ( "destroygif", 
    function ( ) 
        destroyElement ( gif ) 
    end 
) 

Tampoco Funciona :C

Posted

yo use esta funcion una vez ( me dio mucho lagg en mi server ), yo hice esto :

  
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 
) 
  
local sWidth,sHeight = guiGetScreenSize() 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo1.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo2.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo3.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo4.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo5.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo6.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo7.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo8.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo9.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo10.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo11.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo12.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo13.png", 20, 120 ) 
  

Posted

Porque eso que hiciste no tiene sentido, estas creando todas las imagenes como si la funcion no existiese.

@Bc: La posicion debe ser absolute.

Posted
yo use esta funcion una vez ( me dio mucho lagg en mi server ), yo hice esto :
  
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 
) 
  
local sWidth,sHeight = guiGetScreenSize() 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo1.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo2.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo3.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo4.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo5.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo6.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo7.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo8.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo9.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo10.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo11.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo12.png", 20, 120 ) 
gif = dxDrawGifImage (sWidth*0,sHeight*0,sWidth*0.5,sHeight*0.5, "img/logo13.png", 20, 120 ) 
  

No anima la imagen creo que eso solo hace que salga una imagen ensima de la otra

Posted
Porque eso que hiciste no tiene sentido, estas creando todas las imagenes como si la funcion no existiese.

@Bc: La posicion debe ser absolute.

¿Posision absolute?

Bueno yo lo de la posision es lo ultimo que queria ver pero pretendo que la imagen se plasme en la parte superior derecha de la pantalla, ¿Me podrías das un ejemplo?

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

  • Recently Browsing   0 members

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