/** * 跳跃 */ private void _jump() { // 判断是否在地面上 if (PlayerIsOnGround()) { // 1. 改变状态 _curState = PlayerState.JUMP; // 2. 淡入跳跃动画 _jumpState = _armatureComponent.animation.FadeIn("jump", -1.0f, 1, 0, NORMAL_ANIMATION_GROUP, AnimationFadeOutMode.SameGroup); _jumpState.timeScale = 0.7f; // 控制 某个动画状态 的 播放速度 _jumpState.autoFadeOutTime = 0.1f; // 对于限定播放次数的动画, 会自动淡出 // 3. 添加位移 rb.AddForce(new Vector2(0, accel)); // 4. 将 Jump 同组的其他动画停掉, 并设置成 null // 将idel 状态停掉, 并设置成null if (_idelState != null) { _idelState.FadeOut(0.1f); _idelState = null; } // 将run 状态停掉, 并设置成null if (_runState != null) { _runState.FadeOut(0.1f); _runState = null; } } }
private void _fadeOut(AnimationConfig animationConfig) { int i = 0, l = _animationStates.Count; AnimationState animationState = null; switch (animationConfig.fadeOutMode) { case AnimationFadeOutMode.SameLayer: for (; i < l; ++i) { animationState = _animationStates[i]; if (animationState.layer == animationConfig.layer) { animationState.FadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); } } break; case AnimationFadeOutMode.SameGroup: for (; i < l; ++i) { animationState = _animationStates[i]; if (animationState.group == animationConfig.group) { animationState.FadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); } } break; case AnimationFadeOutMode.SameLayerAndGroup: for (; i < l; ++i) { animationState = _animationStates[i]; if (animationState.layer == animationConfig.layer && animationState.group == animationConfig.group ) { animationState.FadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); } } break; case AnimationFadeOutMode.All: for (; i < l; ++i) { animationState = _animationStates[i]; animationState.FadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); } break; case AnimationFadeOutMode.None: default: break; } }
/** * 更新动画 */ private void _updateAnimation() { if (_curState == PlayerState.IDEL) { if (_idelState == null) { if ((_jumpState == null) || (_jumpState != null && !_jumpState.isPlaying)) { _idelState = _armatureComponent.animation.FadeIn("steady", -1.0f, -1, 0, NORMAL_ANIMATION_GROUP, AnimationFadeOutMode.SameGroup); } } if (_runState != null) { // _runState.Stop (); //停止的话, 动作还是保持跑步的状态 _runState.FadeOut(0.1f); //淡出动画 _runState = null; } if (_jumpState != null && !_jumpState.isPlaying) { _jumpState.FadeOut(0.1f); _jumpState = null; } } else if (_curState == PlayerState.RUN) { if (_runState == null) { if ((_jumpState == null) || (_jumpState != null && !_jumpState.isPlaying)) { _runState = _armatureComponent.animation.FadeIn("walk", -1.0f, -1, 0, NORMAL_ANIMATION_GROUP, AnimationFadeOutMode.SameGroup); _runState.timeScale = 1.2f; } } if (_idelState != null) { _idelState.FadeOut(0.1f); _idelState = null; } if (_jumpState != null && !_jumpState.isPlaying) { _jumpState.FadeOut(0.1f); _jumpState = null; } } else { } }
static int FadeOut(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2) { DragonBones.AnimationState obj = (DragonBones.AnimationState)ToLua.CheckObject <DragonBones.AnimationState>(L, 1); float arg0 = (float)LuaDLL.luaL_checknumber(L, 2); obj.FadeOut(arg0); return(0); } else if (count == 3) { DragonBones.AnimationState obj = (DragonBones.AnimationState)ToLua.CheckObject <DragonBones.AnimationState>(L, 1); float arg0 = (float)LuaDLL.luaL_checknumber(L, 2); bool arg1 = LuaDLL.luaL_checkboolean(L, 3); obj.FadeOut(arg0, arg1); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: DragonBones.AnimationState.FadeOut")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int FadeOut(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); DragonBones.AnimationState obj = (DragonBones.AnimationState)ToLua.CheckObject(L, 1, typeof(DragonBones.AnimationState)); float arg0 = (float)LuaDLL.luaL_checknumber(L, 2); bool arg1 = LuaDLL.luaL_checkboolean(L, 3); obj.FadeOut(arg0, arg1); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }