0
\$\begingroup\$

I am making a game, and when the player runs into a certain block it changes the size of a circle on the top. The problem is, whenever the player runs into the block it disappears. How can I fix this?

\$\endgroup\$
1
\$\begingroup\$

What most likely happens from the (very basic and incomplete) description of your issue is that each frame you detect a collision, you reduce the size of the shape. Thus, frame after frame the shape gets smaller and smaller, so much that it's no longer visible.

When you get the collision and you change the size of the shape, you also have to set a flag to tell it to not do it again the following frames. You reset the flag once there is no longer any collision detected.

\$\endgroup\$
0
\$\begingroup\$

It's hard to know what's happening without seeing example code but it could be the order with which you erase and draw the sprites. For example, if you had the following steps:

  1. Erase circle
  2. Draw smaller circle
  3. Erase player <-- this is where you might be erasing the smaller circle
  4. Draw player

If the above is your problem, the fix would be to erase everything, then draw everything in the order you want (e.g. correct layering).

\$\endgroup\$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.