pype是一个由Python/C++语言编写的完整开源的跨平台图形应用框架, 可移植到Windows Linux Android iOS 支持WebAssembly的Web端等(嵌入式MCU除外)。
https://blueloveth.github.io/pype/
from pype import *
def load_fox_anim(name):
anim = FrameAnimation()
anim.frames = load_dir(f"assets/fox/{name}")
anim.speed = 12
anim.loop = True
return anim
class Player(Sprite2D):
def on_ready(self) -> None:
self.scale = 0.5
self.position = Vector2(400, 300)
self.animator = FrameAnimator()
self.animator['run'] = load_fox_anim('run')
self.animator['walk'] = load_fox_anim('walk')
self.animator.parent = self
self.animator.play('walk')
def on_update(self) -> None:
delta_x = 0
if Input.get_key(KeyCode.A):
delta_x -= 1
if Input.get_key(KeyCode.D):
delta_x += 1
if delta_x != 0:
self.animator.play('run')
self.flip = delta_x < 0
else:
self.animator.play('walk')
self.x += delta_x * Time.delta_time * 200
Player()
https://zhuanlan.zhihu.com/p/625784518
你可以按下F5
键执行热重载,这将会重新加载你的Python脚本,并将更新后的代码应用到场景中。
而不用重新编译或重启引擎。
你可以使用Python或者C++编写新的类实现,并提交Pull Request。