cgm2k7 Posted April 22, 2023 at 05:40 PM Share Posted April 22, 2023 at 05:40 PM Boa tarde! Estou criando um pequeno game 2d em directx11, estou na para de animar os sprite. Veja mina duvida: Tenho uma folha de sprite com 18 quadros, 3 linha com 6 colunas. Consigo fazer a animação de modo bem manual. Problema é que se precisar aumentar as colunas ou linhas preciso mudar todo o código da animação. Gostaria se alguém ai puder me ajudar a fazer este código mais automático. esse e o código: [code=delphi]float *v = new float[m_NumRow]; for (size_t i = 0; i < m_NumRow; i++) { v[i] = i*(1.0f/m_NumRow); } float t = 0, k = 1.0f/m_NumRow; if (currentFrame >= m_NumCol) { t = v[1]; } if (currentFrame >= (m_NumCol + m_NumCol)) { t = v[2]; } if (currentFrame < m_NumCol) t = v[0]; m_vertices[0].uv.x = (float)(currentFrame) / m_NumCol; m_vertices[0].uv.y = t + k; m_vertices[1].uv.x = (float)(currentFrame) / m_NumCol; m_vertices[1].uv.y = t; m_vertices[2].uv.x = (float)(currentFrame + 1.0f) / m_NumCol; m_vertices[2].uv.y = t; m_vertices[3].uv.x = (float)(currentFrame + 1.0f) / m_NumCol; m_vertices[3].uv.y = t + k; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.