const {ccclass, property} = cc._decorator;
@ccclass
export class Shake extends cc.ActionInterval
{
private _initial_x:number = 0;
private _initial_y:number = 0;
private _strength_x:number = 0;
private _strength_y:number = 0;
/**
* 创建抖动动画
* @param {number} duration 动画持续时长
* @param {number} strength_x 抖动幅度: x方向
* @param {number} strength_y 抖动幅度: y方向
* @returns {Shake}
*/
public static create(duration:number,strength_x:number,strength_y:number):Shake
{
let act:Shake = new Shake();
act.initWithDuration( duration,strength_x,strength_y );
return act;
}
public initWithDuration(duration:number,strength_x:number,strength_y:number):boolean
{
cc.ActionInterval.prototype['initWithDuration'].apply(this,arguments);
this._strength_x = strength_x;
this._strength_y = strength_y;
return true;
}
public fgRangeRand(min:n
Cocos Creator 震动动画扩展类 (TypeScript)
最新推荐文章于 2024-11-09 08:11:05 发布
本文介绍如何使用TypeScript在Cocos Creator中创建一个震动动画扩展类Shake,包括构造函数、更新方法和各种参数设置,以实现目标节点的随机位移效果。

最低0.47元/天 解锁文章
1912

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



