创建角色 完善

This commit is contained in:
WONIU 2024-12-18 13:46:38 +08:00
parent 0e09a72b8f
commit d1bc68cc3a
1 changed files with 63 additions and 23 deletions

View File

@ -229,6 +229,7 @@ class _CreateCharacter extends Yosin_Window {
auraAni = null;
changJobAniClock = null;
changNextJobAniClock = null;
nextJobIndex = null;
@ -267,7 +268,7 @@ class _CreateCharacter extends Yosin_Window {
// 切换职业
function changJob(index) {
if (index == nextJobIndex) return;
local jobEnum = getJobEnum(index);
@ -302,49 +303,87 @@ class _CreateCharacter extends Yosin_Window {
// 开始切换动画
changJobAniClock = clock();
// 切换动画中不响应点击
headList.clickOff = true;
if (changJobAniClock == null) {
changJobAniClock = clock();
}
changNextJobAniClock = clock();
}
// 切换动画控制
function changJobAniController(progressBlock, doneBlock, next = true) {
/// 切换职业动画
function changJobAni() {
if (changJobAniClock == null) return;
if (next) {
if (changNextJobAniClock == null) {
print("NextNull");
return;
}
}else {
if (changJobAniClock == null) {
print("NUll");
return;
}
}
// 动画的前90%后10%,慢
local ani_progress = Math.sq_GetAccel(0, 100, clock() - changJobAniClock, 0.3, false);
local ani_progress = Math.sq_GetAccel(0, 100, clock() - (next ? changNextJobAniClock : changJobAniClock), 0.3, false);
if (ani_progress >= 90){
ani_progress = Math.sq_GetAccel(0, 10, clock() - changJobAniClock, 0.7, false) + 90 ;
ani_progress = Math.sq_GetAccel(0, 10, clock() - (next ? changNextJobAniClock : changJobAniClock), 0.7, false) + 90 ;
}
local x = ani_progress * 5.0;
jobImg.SetPosition( 0 - x, 0);
nextJobImg.SetPosition(500 - x, 0);
jobImg.SetOpacity( (100.0 - ani_progress.tofloat()) / 100.0 );
// 动画的前90%透明度进度为50%后10%透明度进度为剩下的50%
local opacity = ani_progress.tofloat() / 180.0;
if (opacity > 0.5) opacity = (ani_progress.tofloat() - 90.0) / 20.0 + 0.5;
nextJobImg.SetOpacity( opacity );
if (progressBlock != null) progressBlock(ani_progress);
if (ani_progress >= 100){
if (doneBlock != null) doneBlock();
}
}
/// 切换当前职业动画
function changCurrnentJobAni() {
if (changJobAniClock == null) return;
changJobAniController(function(ani_progress) {
local x = ani_progress * 5.0;
jobImg.SetPosition( 0 - x, 0);
jobImg.SetOpacity( (100.0 - ani_progress.tofloat()) / 100.0 );
}.bindenv(this), function () {
changJobAniClock = null;
}.bindenv(this),false );
}
// 切换职业动画
function changNextJobAni() {
if (changNextJobAniClock == null) return;
changJobAniController(function(ani_progress) {
local x = ani_progress * 5.0;
nextJobImg.SetPosition(500 - x, 0);
// 动画的前90%透明度进度为50%后10%透明度进度为剩下的50%
local opacity = ani_progress.tofloat() / 180.0;
if (opacity > 0.5) opacity = (ani_progress.tofloat() - 90.0) / 20.0 + 0.5;
nextJobImg.SetOpacity( opacity );
}.bindenv(this), function () {
changNextJobAniClock = null;
local jobEnum = getJobEnum(nextJobIndex);
jobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", jobEnum ));
jobImg.SetOpacity(1);
jobImg.SetPosition(0, 0);
if (nextJobIndex < 16) {
nextJobImg.SetFrame(CL_SpriteFrameObject("sprite/interface2/charactercreatever2/basecharctertitle.img", getJobEnum(nextJobIndex + 1)));
nextJobImg.SetOpacity(0);
nextJobImg.SetPosition(500, 0);
}
headList.clickOff = false;
}
}
}.bindenv(this) );
}
function RegisterDraw() {
//大背景
@ -399,8 +438,8 @@ class _CreateCharacter extends Yosin_Window {
SyncPos(X, Y);
base.Proc(Dt);
changJobAni();
changCurrnentJobAni();
changNextJobAni();
}
@ -452,7 +491,7 @@ class _CreateCharacter_SelectBaseInfo extends Yosin_Window {
Addchild(jobChangeText);
//创建角色按钮
local createButton = Yosin_EmeStretch(59, jobChangeTextY + 30, 160, 36, "sprite/interface/lenheartwindowcommon.img", 172);
local createButton = Yosin_SplicingButton(59, jobChangeTextY + 30, 160, 36, "sprite/interface/lenheartwindowcommon.img", 172, true, false);
//点击事件回调
createButton.OnClick = function(Button) {
if (OnClick) OnClick();
@ -460,6 +499,7 @@ class _CreateCharacter_SelectBaseInfo extends Yosin_Window {
// 按钮文本
local createText = CL_SpriteObject("sprite/interface2/charactercreatever2/charctertitle.img", 12);
createText.SetPosition(42.5, 8);
createText.SetZOrder(10000);
createButton.Addchild(createText);
AddUIChild(createButton);