本文介绍了pygame,从角色获取关键对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用pygame制作多人平台游戏/射击游戏/斗殴游戏,我希望玩家可以轻松地更改其键绑定(例如从配置文件中更改).
到目前为止,我还没有找到一种读取字符串并将其用作到pygame.K_xx对象的过渡的方法,所以我问社区.
有线索吗?
解决方案具有此列表您可以使用
getattr(pygame, 'K_'+ mychar)按名称访问常量.
I'm making a multiplayer platformer/shooter/brawl game with pygame and I'd like for the players to easily change their keybinds (such as from a config file).
I haven't been able to find a way to read a character string and use that as a transition to the pygame.K_xx objects as of now so I ask the community.
Any leads ?
解决方案With the constants of this list you can use
getattr(pygame, 'K_'+ mychar)to access a constant by name.
更多推荐
pygame,从角色获取关键对象
发布评论