forked from Rowland/EG
39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
复合动画脚本 - 结合旋转和跳跃效果
|
|
"""
|
|
|
|
from core.script_system import ScriptBase
|
|
import math
|
|
|
|
class ComboAnimatorScript(ScriptBase):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.time = 0.0
|
|
self.original_pos = None
|
|
self.is_active = True
|
|
|
|
def start(self):
|
|
self.log("复合动画脚本启动!")
|
|
self.original_pos = self.gameObject.getPos()
|
|
|
|
def update(self, dt):
|
|
if not self.is_active:
|
|
return
|
|
|
|
self.time += dt
|
|
|
|
# 旋转效果
|
|
current_hpr = self.gameObject.getHpr()
|
|
new_h = current_hpr.getX() + 45.0 * dt
|
|
self.gameObject.setHpr(new_h, current_hpr.getY(), current_hpr.getZ())
|
|
|
|
# 跳跃效果
|
|
if self.original_pos:
|
|
bounce_offset = abs(math.sin(self.time * 3.0)) * 1.0
|
|
self.gameObject.setZ(self.original_pos.getZ() + bounce_offset)
|
|
|
|
def on_destroy(self):
|
|
self.log("复合动画脚本停止") |