arcade最简单的鼠标移动角色

import arcade
 
class MyGame(arcade.Window):     

    def __init__(self):         
        super().__init__(600, 600, "arcade最简单的鼠标移动角色_lixingqiu")
        # 设置背景颜色
        arcade.set_background_color(arcade.color.AMAZON)
        # 实例化玩家
        self.player = arcade.Sprite("character.png")
        self.player.center_x = 50
        self.player.center_y = 50
        
    def on_draw(self):
        """每帧都会自动重画所有对象 """
        arcade.start_render()    
        self.player.draw()
 
    def on_mouse_motion(self, x, y, dx, dy):
        """当鼠标指针移动时会自动调用此方法""" 
        self.player.center_x = x # 把角色x坐标设定为鼠标x坐标
        self.player.center_y = y # 把角色y坐标设定为鼠标y坐标

if __name__ == "__main__":
    
    window = MyGame()   
    arcade.run()