void TurnInTween(GTweener tweener) { bool toOpen = (bool)tweener.userData; float v = tweener.value.x; if (toOpen) { _back.rotationY = v; _front.rotationY = -180 + v; if (v > 90) { _front.visible = true; _back.visible = false; } } else { _back.rotationY = -180 + v; _front.rotationY = v; if (v > 90) { _front.visible = false; _back.visible = true; } } }
void OnTurnComplete(GTweener tweener) { bool suc = (bool)tweener.userData; _draggingCorner = Corner.INVALID; if (suc && _turningTarget != -1) { _currentPage = _turningTarget; } if (suc && _coverTurningOp != CoverTurningOp.None) { if (_coverTurningOp == CoverTurningOp.ShowFront) { _coverStatus = CoverStatus.ShowingFront; } else if (_coverTurningOp == CoverTurningOp.ShowBack) { _coverStatus = CoverStatus.ShowingBack; } else { _coverStatus = CoverStatus.Hidden; } } _coverTurningOp = CoverTurningOp.None; _turningTarget = -1; RenderPages(); DispatchEvent("onTurnComplete"); }
//渲染roomList private void RenderListItem(int index, GObject obj) { GButton roomButton = obj.asButton; roomButton.title = rooms[index].roomName; if (rooms[index].currentPlayer.Count >= rooms[index].limitNum) { roomButton.enabled = false; } GTextField textField = roomButton.GetChild("title").asTextField; //点击房间,显示详细信息 roomButton.onClick.Add(() => { currentRoom = rooms[index]; roomListComponent.GetChild("entryRoomButton").asButton.enabled = true; if (roomInfoWindow != null) { roomInfoWindow.Dispose(); } //窗口平行显示在roomButton左侧,需要list位置和scrollpane的滚动比例 roomInfoWindow = new RoomInfoWindow(rooms[index], roomList.x, roomList.y, roomList.height, roomList.scrollPane.contentHeight, roomButton.y, roomList.scrollPane.percY); //Debug.Log("percY:"+roomList.scrollPane.percY); roomInfoWindow.Show(); //文本域超出显示范围,滚动 if (textField.width > roomButton.width) {//调整文本域的位置,使文本域向左移动 tweener = textField.TweenMove(new Vector2(roomList.width - textField.width, 0), 2.0f).OnComplete(() => { //播放完成后清空tweener,重置位置 tweener = null; textField.SetXY(0, 0); }); } }); }
//开始触摸 private void OnTouchBegin(EventContext evenContext) { if (touchID == -1)//第一次触摸 { InputEvent inputEvent = (InputEvent)evenContext.data; touchID = inputEvent.touchId; if (tweener != null) { tweener.Kill();//终止上一个动效 tweener = null; } Vector2 localPos = GRoot.inst.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y)); float posX = localPos.x; float posY = localPos.y; joystickButton.selected = true; lastStageX = posX; lastStageY = posY; startStageX = posX; startStageY = posY; joystickCenter.visible = true; joystickCenter.SetXY(posX - joystickCenter.width / 2, posY - joystickCenter.height / 2); joystickButton.SetXY(posX - joystickButton.width / 2, posY - joystickButton.height / 2); evenContext.CaptureTouch(); } }
//结束触摸 private void OnTouchEnd(EventContext context) { InputEvent inputEvent = (InputEvent)context.data; //触摸中 if (touchID != -1 && inputEvent.touchId == touchID) { //设置为结束触摸 touchID = -1; //将杆子旋转180度 thumb.rotation = thumb.rotation + 180; //隐藏摇杆中心 center.visible = false; //启动移动动画 设置目标位置与移动时间 tweener = joystickButton.TweenMove(new Vector2(initX - joystickButton.width / 2, initY - joystickButton.height / 2), 0.3f).OnComplete(() => { //结束的回调方法 tweener = null; joystickButton.selected = false; thumb.rotation = 0; center.visible = true; center.SetXY(initX - center.width / 2, initY - center.height / 2); } ); } //回调函数 onEnd.Call(); }
private void OnTouchBegin(EventContext context) { if (touchID == -1) { InputEvent inputEvent = (InputEvent)context.data; touchID = inputEvent.touchId; if (tweener != null) { tweener.Kill(); tweener = null; } Vector2 localPos = GRoot.inst.GlobalToLocal(inputEvent.position); startPos = localPos; SetCenterPosXY(center, localPos); center.visible = false; SetCenterPosXY(thumb, localPos); thumb.visible = true; Vector2 dir = new Vector2(startPos.x - initPos.x, startPos.y - initPos.y); float radian = Mathf.Atan2(dir.y, dir.x); float degree = radian * 180 / Mathf.PI; thumb.rotation = degree + 90; context.CaptureTouch(); // Debug.Log("===============>TouchBegin"+degree); } }
public void starttweener() { tweener = taget.TweenFade(0f, 1f).OnComplete(() => { taget.visible = false; apha = false; }); }
/// <summary> /// 内部接口 进入动画效果 /// </summary> public void DoShowAnimation() { if (_contentPane == null) { return; } _originPos = _window.xy; string ani = animation[0]; if (ani == null) { return; } GTweener tween = null; switch (ani) { case "eject": //放大 _window.SetScale(0.9f, 0.9f); tween = _window.TweenScale(new Vector2(1f, 1f), 0.3f); TweenUtils.SetEase(tween, EaseType.BackOut); TweenUtils.OnComplete(tween, CallOnShown); break; case "fade_in": //淡入 _window.alpha = 0; tween = _window.TweenFade(1, 0.3f); TweenUtils.SetEase(tween, EaseType.QuadOut); TweenUtils.OnComplete(tween, CallOnShown); break; case "move_up": //上滑进入 _window.y = GRoot.inst.height; tween = _window.TweenMoveY(_originPos.y, 0.3f); TweenUtils.SetEase(tween, EaseType.QuadOut); TweenUtils.OnComplete(tween, CallOnShown); break; case "move_left": //左滑动进入 _window.x = GRoot.inst.width; tween = _window.TweenMoveX(_originPos.x, 0.3f); TweenUtils.SetEase(tween, EaseType.QuadOut); TweenUtils.OnComplete(tween, CallOnShown); break; case "move_right": //右滑进入 _window.x = -GRoot.inst.width - 30; tween = _window.TweenMoveX(_originPos.x, 0.3f); TweenUtils.SetEase(tween, EaseType.QuadOut); TweenUtils.OnComplete(tween, CallOnShown); break; default: CallOnShown(); break; } }
private void OnPlayFinish() { if (m_GTweener != null) { m_GTweener.Kill(); m_GTweener = null; } OnGameOver(m_UI.m_Sword.rotation >= -110 && m_UI.m_Sword.rotation <= -85); }
void OnTurnUpdate(GTweener tweener) { _dragPoint = tweener.value.vec2; _turningAmount = _dragPoint.x / (_coverTurningOp != CoverTurningOp.None ? _frontCover.width * 2 : _pageWidth * 2); if (_draggingCorner == Corner.TR || _draggingCorner == Corner.BR) { _turningAmount = 1 - _turningAmount; } PlayTurnEffect(); }
//打断动画进程 add by tianjinpeng 2018/03/14 10:33:03 void killtweener(GTweener tweener) { if (tweener != null) { GTween.Kill(tweener); tweener = null; } else { } }
private void OnTouchBegin(EventContext context) { if (touchId == -1) //First touch { InputEvent evt = (InputEvent)context.data; touchId = evt.touchId; if (_tweener != null) { _tweener.Kill(); _tweener = null; } Vector2 pt = GRoot.inst.GlobalToLocal(new Vector2(evt.x, evt.y)); float bx = pt.x; float by = pt.y; if (bx < 0) { bx = 0; } else if (bx > _touchArea.width) { bx = _touchArea.width; } if (by > GRoot.inst.height) { by = GRoot.inst.height; } else if (by < _touchArea.y) { by = _touchArea.y; } _lastStageX = bx; _lastStageY = by; _startStageX = _InitX; _startStageY = _InitY; _center.visible = true; //_center.SetXY(bx - _center.width / 2, by - _center.height / 2); _joystick_button.SetXY(bx - _joystick_button.width / 2, by - _joystick_button.height / 2); float deltaX = bx - _InitX; float deltaY = by - _InitY; float degrees = Mathf.Atan2(deltaY, deltaX) * 180 / Mathf.PI; _thumb.rotation = degrees + 90; _thumb.visible = true; _joystick_button.visible = true; context.CaptureTouch(); handleInput(bx, by); } }
public void Hide(bool withAnim = true) { if (choicebubbletweener != null) { GTween.Kill(choicebubbletweener); } choicebubbletweener = ui.TweenFade(0, 0.2f).OnComplete(() => { ui.visible = false; choicebubbletweener = null; }); }
public void Add(string iconurl, string nametext, string datacount) { CanToZero(); float toy = 300f - ((tipsDatas.Count + 1) * 100f); newtipsData(iconurl, nametext, datacount); if (tweener != null) { GTween.Kill(tweener); } tweener = gList.TweenMoveY(toy, 0.3f); }
public void Show(bool withAnim = true) { ui.visible = true; if (choicebubbletweener != null) { GTween.Kill(choicebubbletweener); } choicebubbletweener = ui.TweenFade(1, 0.2f).OnComplete(() => { choicebubbletweener = null; }); }
public void Movesize(GObject parent, GObject gameObject, Vector2 sd, Vector2 pos, float time) { parent.position = sd; parent.visible = true; GTween.Kill(dosettw); GTween.Kill(movesizepar); dosettw = parent.TweenResize(gameObject.size, time); movesizepar = parent.TweenMove(pos, time).OnComplete(() => { gameObject.visible = true; parent.visible = false; }); }
/// <summary> /// 内部接口 退出动画效果 /// </summary> public void DoHideAnimation() { _originPos = _window.xy; string ani = animation[1]; if (ani == null) { return; } GTweener tween = null; switch (ani) { case "shrink": //缩小 _window.SetScale(1, 1); tween = _window.TweenScale(new Vector2(0.8f, 0.8f), 0.2f); TweenUtils.SetEase(tween, EaseType.ExpoIn); TweenUtils.OnComplete(tween, DoHide); break; case "fade_out": //淡出 _window.alpha = 0; tween = _window.TweenFade(1, 0.3f); TweenUtils.SetEase(tween, EaseType.BackOut); TweenUtils.OnComplete(tween, DoHide); break; case "move_down": //下滑退出 tween = _window.TweenMoveY(GRoot.inst.height + 30, 0.3f); TweenUtils.SetEase(tween, EaseType.QuadOut); TweenUtils.OnComplete(tween, DoHide); break; case "move_left": //左滑动退出 tween = _window.TweenMoveX(-_window.width - 30, 0.3f); TweenUtils.SetEase(tween, EaseType.QuadOut); TweenUtils.OnComplete(tween, DoHide); break; case "move_right": //右滑退出 tween = _window.TweenMoveX(-_window.width + 30, 0.3f); TweenUtils.SetEase(tween, EaseType.QuadOut); TweenUtils.OnComplete(tween, DoHide); break; default: DoHide(); break; } }
public static void OnComplete(GTweener tweener, Action func) { tweener.OnComplete(() => { try { func(); } catch (Exception e) { Debug.LogError(e); } func = null; }); }
//右列表选择框位置调整 add by tianjinpeng 2018/03/09 15:29:54 void choicepos(int index) { if (baglist.numItems == 0) { } else { Vector2 screenPos = baglist.GetChildAt(index).LocalToGlobal(Vector2.zero); Vector2 sPos = new Vector2(screenPos.x - 2, screenPos.y - 1); Vector2 logicScreenPos = storeup.GlobalToLocal(sPos); //choice.position = new Vector2(logicScreenPos.x, logicScreenPos.y); killtweener(choicemove); choicemove = choice.TweenMove(logicScreenPos, 0.1f); } }
public void Hide(bool withAnim = true) { killtweener(storeuptweener); storeuptweener = storeup.TweenMoveY(0, 0.2f).OnComplete(() => { ui.visible = false; storeup.visible = false; });; if (storedown.visible == true) { killtweener(storedowntweener); storedowntweener = storedown.TweenMoveY(1080, 0.2f).OnComplete(() => { storedown.visible = false; });; } }
public void Hide(bool withAnim = true) { if (withAnim) { if (gTweener_progressBar_fode != null) { GTween.Kill(gTweener_progressBar_fode); } gTweener_progressBar_fode = bosshpcomponent.TweenFade(0f, 0.7f).OnComplete(() => { bosshpcomponent.visible = false; gTweener_progressBar_fode = null; }); } else { bosshpcomponent.visible = false; } }
//结束触摸,joystickButton返回joystickCenter private void OnTouchEnd(EventContext evenContext) { InputEvent inputEvent = (InputEvent)evenContext.data; if (touchID != -1 && touchID == inputEvent.touchId) { touchID = -1; thumb.rotation = thumb.rotation + 180;//指向圆心 joystickCenter.visible = false; tweener = joystickButton.TweenMove(new Vector2(initX - joystickButton.width / 2, initY - joystickButton.height / 2), 0.3f).OnComplete(() => { tweener = null; joystickButton.selected = false; thumb.rotation = 0; joystickCenter.visible = true; joystickCenter.SetXY(initX - joystickCenter.width / 2, initY - joystickCenter.height); }); } onEnd.Call(); }
private void OnTouchEnd(EventContext context) { InputEvent inputEvent = (InputEvent)context.data; if (touchID != -1 && inputEvent.touchId == touchID) { touchID = -1; center.visible = false; tweener = thumb.TweenMove(GetReduceHalfWHPos(initPos, thumb), 0.3f).OnComplete(() => { SetCenterPosXY(center, initPos); center.visible = true; thumb.rotation = 0; thumb.visible = false; }); // Debug.Log("===============>TouchEnd"); } onEnd.Call(); }
void killtweener(GTweener kill, GTweener newfsf, GObject parent, bool onoff) { if (kill != null) { GTween.Kill(kill); kill = newfsf; } else { kill = newfsf; } newfsf.OnComplete(() => { if (onoff) { } else { parent.visible = false; } }); }
public static void OnComplete(GTweener tweener, Action <object> func, object self) { tweener.OnComplete(() => { try { if (self != null) { func(self); } } catch (Exception e) { Debug.LogError(e); } func = null; if (self != null) { self = null; } }); }
private void OnTouchEnd(EventContext context) { InputEvent inputEvt = (InputEvent)context.data; if (touchId != -1 && inputEvt.touchId == touchId) { touchId = -1; _thumb.rotation = _thumb.rotation + 180; _center.visible = false; _tweener = _button.TweenMove(new Vector2(_InitX - _button.width / 2, _InitY - _button.height / 2), 0.3f).OnComplete(() => { _tweener = null; _button.selected = false; _thumb.rotation = 0; _center.visible = true; _center.SetXY(_InitX - _center.width / 2, _InitY - _center.height / 2); } ); this.onEnd.Call(); } }
void choiceleftpos(int qwe) { Vector2 screenPos = new Vector2(LeftList[qwe].position.x + 1, LeftList[qwe].position.y); //leftchoice.position = new Vector2(screenPos.x, screenPos.y); killtweener(choicemove); choicemove = leftchoice.TweenMove(screenPos, 0.1f); int i; for (i = 0; i < 4; i++) { if (qwe == i) { LeftList[i].visible = true; textlist[i].alpha = 1f; } else { LeftList[i].visible = false; textlist[i].alpha = 0.3f; } } Import(); }
//开始触摸 private void OnTouchBegin(EventContext context) { if (touchID == -1)//第一次触摸 { InputEvent inputEvent = (InputEvent)context.data; touchID = inputEvent.touchId; if (tweener != null) { tweener.Kill();//杀死上一个动画 tweener = null; } //将世界坐标转化为FGUI坐标 Vector2 localPos = GRoot.inst.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y)); float posX = localPos.x; float posY = localPos.y; //注意此处为单选按钮,需要设置单选属性 选中设为true joystickButton.selected = true; lastStageX = posX; lastStageY = posY; startStageX = posX; startStageY = posY; //设置新的摇杆按钮与中心位置 center.visible = true; center.SetXY(posX - center.width / 2, posY - center.height / 2); joystickButton.SetXY(posX - joystickButton.width / 2, posY - joystickButton.height / 2); float deltaX = posX - initX; float deltay = posY - initY; //计算旋转角度 float degrees = Mathf.Atan2(deltay, deltaX) * 180 / Mathf.PI; thumb.rotation = degrees + 90; //上下文获取触摸状态 context.CaptureTouch(); } }
void closestoreuptw() { killtweener(storeuptweener); storeuptweener = storeup.TweenMoveY(0, 0.2f).OnComplete(() => { storeup.visible = false; });; }
void closestoredowntw() { killtweener(storedowntweener); storedowntweener = storedown.TweenMoveY(1080, 0.2f).OnComplete(() => { storedown.visible = false; });; }