Home:ALL Converter>Pygame - How to check if object is currently moving

Pygame - How to check if object is currently moving

Ask Time:2020-09-01T19:20:17         Author:Kantolo

Json Formatter

As the title says, How do I check to see if an object (in this case, a rect) is currently moving in pygame.

I've tried to create a variable of the previous position and see if the current position matches, but it just flickers between "True" and "False", which I'm assuming is because the object's location isn't changing faster than the game's update ticks

I'm currently changing the object's position by using:

def MoveButton(self,new_xpos,new_ypos):
    self.x_pos = new_xpos
    self.y_pos = new_ypos

Which is a function inside the object's class, and is being called constantly via key press.

Author:Kantolo,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/63686647/pygame-how-to-check-if-object-is-currently-moving
yy