c++ - Method not being called in switch statement -


EDIT: Now works perfectly in the debugger, but usually the block does not rotate while walking.

I have a problem that I have run a ton through the debugger and it has narrowed it down.

I have got a block on the screen which comes in between and rotates. Obviously the image of the block depends on the rotation, and it is done in a switch statement.

  switch (m_CurrentRotation) {case BossRotation_ZeroDegrees: {Apply field (m_BossRect.topLeftX, m_BossRect.topLeftY, bosfive image :: p_ZeroDegrees, p_Buffer); break; } Case BossRotation_NinetyDegrees: {Apply surface (m_BossRect.topLeftX, m_BossRect.topLeftY, BossFiveImage :: p_NinetyDegrees, p_Buffer); break; } Case BossRotation_OneEightyDegrees: {Apply surface (m_BossRect.topLeftX, m_BossRect.topLeftY, BossFiveImage :: p_OneEightyDegrees, p_Buffer); break; } Case BossRotation_TwoSeventyDegrees: {Apply Apply (m_BossRect.topLeftX, m_BossRect.topLeftY, BossFiveImage :: p_TwoSeventyDegrees, p_Buffer); break; } Default: {}}  

The block goes to zero degrees, and once it gets in the middle it starts rotating. I have found debugging that in the switch statement, the ApplySurface is not being called for the first case (when I try to move in, nothing happens). Due to this the block is "empty" at that rotation point.

Here are the weird things ...

1) If applicable, if not called theformfus, why are you coming to the block earlier (before starting to rotate)?

2) Running a program in the debugger and running it usually show different results. Generally, it only shows the block all the time in its zero degree position. Debugger is the only time that actually tries to rotate the block. What is the compiler optimization going on, which is stopping what's going wrong in my switch statement?

"post-text" itemprop = "text">

Your code seems to be unnecessarily long and repetitive, it should be refined again:

  Image = NULL; Switch (m_CurrentRotation) {case BossRotation_ZeroDegrees: {image = BossFiveImage :: p_ZeroDegrees; break; } Case BossRotation_NinetyDegrees: {image = BossFiveImage :: p_NinetyDegrees; break; } Case BossRotation_OneEightyDegrees: {image = BossFiveImage :: p_OneEightyDegrees; break; } Case BossRotation_TwoSeventyDegrees: {image = BossFiveImage :: p_TwoSeventyDegrees; break; } Default: {}} If (Image) {Apply Apply (m_BossRect.topLeftX, m_BossRect.topLeftY, Image, p_Buffer); }  

This simple code should also be easy to debug. What are the types and potential values ​​of M_CurrentRotation?


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -