Starling中MovieClip倒序,反向播放

本文介绍了一种在Starling中实现MovieClip反向播放的方法,通过创建新的纹理和声音数组,并调整当前帧的位置来达到反向播放的效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

关于Starling中的MovieClip反向、倒序播放实现

暂时想到的,修改内容最少的方法了


package com.liyunpeng.xxx
{
import flash.media.Sound;

import starling.animation.IAnimatable;
import starling.display.MovieClip;
import starling.textures.Texture;

public class MMovieClip extends MovieClip implements IAnimatable
{
private var _isReverse:Boolean = false;

public function MMovieClip(textures:Vector.<Texture>, fps:Number=12)
{
super(textures,fps);
}

public function set isReverse(value:Boolean):void
{
if(this._isReverse != value) {
var numFrames:int = this.numFrames;

var mTextures:Vector.<Texture> = new Vector.<Texture>();
var mSounds:Vector.<Sound> = new Vector.<Sound>();
var mDurations:Vector.<Number> = new Vector.<Number>();

for(var i:int=numFrames-1;i>=0;i--) {
mTextures.push(this.getFrameTexture(i));
mSounds.push(this.getFrameSound(i));
mDurations.push(this.getFrameDuration(i));
}

for(var j:int=0;j<numFrames;j++) {
this.setFrameTexture(j,mTextures[j]);
}

this.currentFrame = numFrames-1 - this.currentFrame;
}

this._isReverse = value;
}

public function get isReverse():Boolean
{
return this._isReverse;
}
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值