跳ね返りと摩擦に関する公式
- 範囲の外にあるオブジェクトの削除
-
if (sprite.x - sprite.width / 2 > right || sprite.x + sprite.width / 2 < left || sprite.y - sprite.height / 2 > bottom || sprite.y + sprite.height / 2 < top) { //ここにスプライトを削除するコードを記述 }
- 範囲の外にあるオブジェクトの再作成
-
if (sprite.x - sprite.width / 2 > right || sprite.x + sprite.width / 2 < left || sprite.y - sprite.height / 2 > bottom || sprite.y + sprite.height / 2 < top) { //ここでスプライトの位置と速度をリセットします }
- 範囲の外にあるオブジェクトのスクリーンラッピング
-
if (sprite.x - sprite.width / 2 > right) { sprite.x = left - sprite.width / 2; } else if (sprite.x + sprite.width / 2 < left) { sprite.x = right + sprite.width/2; } if (sprite.y - sprite.height / 2 > bottom) { sprite.y = top - sprite.height / 2; } else if (sprite.y + sprite.height/ 2 >top) { sprite.y = bottom + sprite.height / 2; }
- 摩擦の適用(正しい方法)
-
var speed:Number = Math.sqrt(vx * vx + vy * vy); var angle:Number = Math.atan2(vy, vx); if (speed > friction) { speed -= friction; } else { speed = 0; } vx = Math.cos(angle) * speed; vy = Math.sin(angle) * speed;
- 摩擦の適用(簡単な方法)
-
vx *= friction; vy *= friction;
ActionScript 3.0 アニメーション
posted with amazlet at 08.09.12
Keith Peters
ボーンデジタル
売り上げランキング: 41253
ボーンデジタル
売り上げランキング: 41253
おすすめ度の平均: 

数学嫌いのデザイナーにオススメ
まるでアルゴリズム大辞典
初心者でもなんとか読める
教科書にしたいくらい素晴らしい本