1
$\begingroup$

I have tried in several ways that my character make the animation to move with python and sprites that I have, but at the time of running does absolutely nothing, the strange thing is that in my first test with another character with fewer sprites if he loaded the code

this is the code for anyone who wants to see it:

from bge import logic as GL 
cont = GL.getCurrentController() 
own = cont.owner 

#The recomended max. speed is 0.10 and the min. is 0.009
mesh = own.meshes[0]
array = mesh.getVertexArrayLength(0)


####### SENSORES

sensor = cont.sensors["teclado"]
jump = cont.sensors["salto"]

# STATUS=1 JUST PRESSED
# STATUS=3 JUST RELEASED

# get status of the A key
AKEY= sensor.getKeyStatus(97)
SKEY= sensor.getKeyStatus(115)
DKEY= sensor.getKeyStatus(100)
WKEY= sensor.getKeyStatus(119)
SHIFTKEY= sensor.getKeyStatus(129)
SPACEKEY= sensor.getKeyStatus(32)
LEFTCTRLKEY = sensor.getKeyStatus(124)

animaciones = 12


frames=1 # por defecto la animacion de parado

if AKEY==2 or DKEY==2:  #andar
    own["animacion"]=1/animaciones  
    frames=8

if AKEY==0 and DKEY==0: #parado 
    own["animacion"]=0.0 / animaciones
    frames=1


if jump.positive==False : #saltando 
    own["animacion"]=2/ animaciones
    frames=6


   # numero de animaciones de mi imagen
animacion = 1/animaciones      #animación que se ejecuta 


# si la animacion es la de la primera linea animacion = 0/3 la de abajo es 1/3 y la de enmedio es 2/3
if own["n"]==0: 
    for v in range(0,array):
        vert = mesh.getVertex(0,v) 
        GL.matriz[v] = vert.getUV() 
        GL.matriz0 = GL.matriz


for v in range(0,array):
    vert = mesh.getVertex(0,v) 
    uv = vert.getUV() 
    uv[0] += own["x"]
    vert.setUV(uv)  


if own["n"]>frames or own["n"]==0:
    own["n"]= 1

    for v in range(0,array):
        vert = mesh.getVertex(0,v)  
        uv[0] =GL.matriz0[v][0]
        uv[1] =GL.matriz0[v][1]
        uv[1] += own["animacion"]
        vert.setUV(uv)



own["n"]+= 1
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.