跳转至

MobDoAction 角色执行动作

格式

MobDoAction(mobId, begin, end, speed, loop)

简介

设置角色执行动作。

参数

名称 类型 描述
mobId int 角色ID
begin int 起始动作帧/总帧数
end int 结束动作帧/总帧数
speed float 动作速度
loop bool 是否循环动作,True为循环动作,False为不循环动作

实例

按下鼠标左键时设置角色mob以速度1循环执行动作文件0-1动作帧/总帧数。

import fg
import wx
import vmath

asset = fg.AssetCreate()
asset.name = 'Main Scene'
asset.state = fg.STATE.VOXMODEL
asset.vmFile = 'mainScene'
asset.icon='icon.png'

fg.AssetRegister(asset)

mob = fg.AssetCreate()
mob.name = 'mob'
mob.state = fg.STATE.MOBILE
mob.mobSkeleton = 'skeleton.ozz'
mob.mobMesh = 'mesh.ozz'
mob.mobTexture = 'texture.png'
mob.mobAction = 'action.ozz'
mob.icon='mob.png'

def onStart(self):
    global mob
    mob=fg.AssetBuildEntity(fg.AssetRegister(mob), self.id, vmath.Vec3(0, 25, 0))

def onmouse(self, stamp, button, action, mods):
    if button==wx.MOUSE_BUTTON.LEFT and action==wx.ACTION.PRESS:
        wx.MobDoAction(mob.id, 0, 1, 1, True)

fg.AssetSetStartCBFunc(asset, onStart)
fg.AssetSetMouseButtonCBFunc(asset, onmouse)