S
S
Sedovat2018-08-07 11:58:45
C++ / C#
Sedovat, 2018-08-07 11:58:45

How to control key animation in c++?

Hello, could you tell me what code you need to write to control the animation in c ++, that is, so that when an object is pressed, let's move to the left, and then when it moves to the left, we press another and the movement changes to the right

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RabraBabr, 2018-08-07
@RabraBabr

Well, for example, to catch the message of pressing the corresponding key and change the coordinates of the object. Here in MFC something like this for example.

BOOL CMainWindow::PreTranslateMessage(MSG* pMsg) 
{
  if( pMsg->message == WM_KEYDOWN)
  {
        if (pMsg->wParam == VK_SPACE) 
        {
            // поймали нажатие пробела, что то там делаем, например меняем координату;
            x += 5;
        }
    }
}

In general, a few clarifications are needed to answer the question. For example, what framework do you have?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question