@ccclass
export default class TypeString extends cc.Component {
public textlabelOne:string=" 勇士,拾取装备可提升攻击力";
public textlabelTwo:string="您可击杀攻击力不高于您的怪物,并获得与怪物同等数值的攻击力加成";
public textlableThree:string="塔内可以拾取三种颜色的钥匙,拥有钥匙才能打开对应颜色的门";
public textlabelFour:string="点击地图可开启自动寻路功能,快用钥匙去打开这扇门吧";
public textlabelFive:string="成功抵达楼梯处,即可通过本层关卡!";
step=0;
arr:Array<any> =new Array();
len:number=0;
@property(cc.Label)
thisString:cc.Label=null;
@property(cc.Node)
thisNode:cc.Node=null;
start()
{
// this.RefreshText(this.textlabelOne);
this.RefreshTextOther(this.textlabelOne);
}
callbacktype()
{
this.thisString.string+=this.arr[this.step];
this.step++;
if(this.step==this.len)
{
this.unschedule(this.callbacktype);
}
}
public RefreshText(textstring:string)
{
this.thisString.string=null;
this.step=0;
let arrText:Array<any>=textstring.split('');
this.arr=arrText;
let len:number=arrText.length;
this.len=len;
this.thisString.string="";
this.schedule(this.callbacktype,0.2,len,0.2);
}
public RefreshTextOther(textstring:string)
{
this.thisString.string=textstring;
}
}
cocoscreator逐字打印文章语句
最新推荐文章于 2026-08-08 14:25:49 发布
本文介绍如何利用CocosCreator的游戏引擎,结合JavaScript编程,实现文字动画效果,让文章中的每个字逐个显示,提升用户体验。

2680

被折叠的 条评论
为什么被折叠?



