我想添加功能到我的照片庫 - 不同類型的照片的拇指動畫。現在我確實喜歡下面的代碼。一切正常,但我希望拇指從舞臺的邊緣反彈。簡單的as3動畫模式
而且最重要的是,我需要動畫的不同模式 - 運動作爲3D旋轉木馬,在一個圓圈旋轉,太陽光線的運動和背部等
,如果你有一個我將不勝感激現成的這些和類似動畫的代碼片段。
[Bindable] private var stageW:int = Capabilities.screenResolutionX;
[Bindable] private var stageH:int = Capabilities.screenResolutionY;
private var itemsVector:Vector.<Image>=new Vector.<Image>();
private var xSpeedVector:Vector.<Number>=new Vector.<Number>();
private var ySpeedVector:Vector.<Number>=new Vector.<Number>();
stage.addEventListener(Event.ENTER_FRAME, update);
private function moveSetup():void {
for(var i:int = 0; i < FlexGlobals.topLevelApplication.objects.length; i++){
if (FlexGlobals.topLevelApplication.objects[i] is Image){
var item:Image=FlexGlobals.topLevelApplication.objects[i] as Image;
item.x=Math.random()*stageW;
item.y=Math.random()*stageH;
var randomDirection:Number=Math.random()*2*Math.PI;
this.addElement(item);
itemsVector.push(item);
xSpeedVector.push(2*Math.cos(randomDirection));
ySpeedVector.push(2*Math.sin(randomDirection));
}
}
}
protected function update(event:Event):void {
for(var i:uint=0;i<itemsVector.length;i++){
itemsVector[i].x+=xSpeedVector[i];
itemsVector[i].y+=ySpeedVector[i];
if(itemsVector[i].x>stageW){
itemsVector[i].x-=stageW;
}
if(itemsVector[i].x<0){
itemsVector[i].x+=stageW;
}
if(itemsVector[i].y>stageH){
itemsVector[i].y-=stageH;
}
if(itemsVector[i].y<0){
itemsVector[i].y+=stageH;
}
}
}
[Stack Overflow不是您的個人研究助理](http://meta.stackexchange.com/a/128553/157159) –
ОК。 「我希望大拇指從舞臺邊緣反彈。」 – Astraport