| 50 | | var matrix:Matrix = new Matrix(); |
|---|
| 51 | | matrix.createGradientBox(fireW,fireH,Math.PI/2,-fireW/2,-fireH*(focalPointRatio+1)/2); |
|---|
| 52 | | //var colors:Array = [fireColerIn, fireColerOut, fireColerOut]; |
|---|
| 53 | | var colors:Array = [fireColorIn, fireColorOut, fireColorOut]; |
|---|
| 54 | | var alphas:Array = [1,1,0]; |
|---|
| 55 | | var ratios:Array = [30, 100, 220]; |
|---|
| 56 | | |
|---|
| 57 | | var home:Sprite = new Sprite(); |
|---|
| 58 | | ball = new Sprite(); |
|---|
| 59 | | //炎本体 |
|---|
| 60 | | ball.graphics.beginGradientFill(GradientType.RADIAL,colors, alphas, ratios, matrix,"pad","rgb",focalPointRatio); |
|---|
| 61 | | ball.graphics.drawEllipse(-fireW/2,-fireH*(focalPointRatio+1)/2,fireW,fireH); |
|---|
| 62 | | ball.graphics.endFill(); |
|---|
| 63 | | //余白確保用透明矩形 |
|---|
| 64 | | ball.graphics.beginFill(0x000000,0); |
|---|
| 65 | | ball.graphics.drawRect(-fireW/2,0,fireW+margin,1); |
|---|
| 66 | | ball.graphics.endFill(); |
|---|
| | 56 | this.changeFire(fireWidth, fireHeight, fireColorIn, fireColorOut); |
|---|
| 73 | | //ゆらぎ用のBitmap(ステージに貼付ける必要はないのでBitmapに貼る必要はない) |
|---|
| 74 | | displaceImage = new BitmapData(fireW+margin,fireH,false,0xFFFFFFFF); |
|---|
| 75 | | //火の芯付近の揺らぎを抑える用のグラデーション |
|---|
| 76 | | var matrix2:Matrix = new Matrix(); |
|---|
| 77 | | matrix2.createGradientBox(fireW+margin,fireH,Math.PI/2,0,0); |
|---|
| 78 | | var gradient_mc:Sprite = new Sprite; |
|---|
| 79 | | gradient_mc.graphics.beginGradientFill(GradientType.LINEAR,[0x666666,0x666666], [0,1], [120,220], matrix2); |
|---|
| 80 | | gradient_mc.graphics.drawRect(0,0,fireW+margin,fireH);//drawのターゲットなので生成位置にこだわる必要はない。 |
|---|
| 81 | | gradient_mc.graphics.endFill(); |
|---|
| 82 | | gradientImage = new BitmapData(fireW+margin,fireH,true,0x00FFFFFF); |
|---|
| 83 | | gradientImage.draw(gradient_mc);//gradient_mcを消す必要は? |
|---|
| 84 | | //同サイズの炎の揺らぎをランダム化 |
|---|
| 85 | | rdm = Math.floor(Math.random()*10); |
|---|
| 86 | | |
|---|
| | 62 | //ゆらぎは、他のSprite等にaddChildされた時のみ行うようにする |
|---|
| | 63 | addEventListener(Event.ADDED, function(e:Event):void { |
|---|
| | 64 | addEventListener(Event.ENTER_FRAME,loop); |
|---|
| | 65 | }); |
|---|
| | 66 | addEventListener(Event.REMOVED, function(e:Event):void { |
|---|
| | 67 | removeEventListener(Event.ENTER_FRAME, loop); |
|---|
| | 68 | }); |
|---|
| | 93 | |
|---|
| | 94 | /** |
|---|
| | 95 | * 炎の大きさと色を変更する |
|---|
| | 96 | * @param fireWidth 炎の幅 |
|---|
| | 97 | * @param fireHeight 炎の高さ |
|---|
| | 98 | * @param fireColorIn 炎の内側部分の色 |
|---|
| | 99 | * @param fireColorOut 炎の外側部分の色 |
|---|
| | 100 | */ |
|---|
| | 101 | public function changeFire(fireWidth:Number = 30, |
|---|
| | 102 | fireHeight:Number = 90, |
|---|
| | 103 | fireColorIn:uint = 0xFFCC00, |
|---|
| | 104 | fireColorOut:uint = 0xE22D09):void { |
|---|
| | 105 | fireW = fireWidth; |
|---|
| | 106 | fireH = fireHeight; |
|---|
| | 107 | var matrix:Matrix = new Matrix(); |
|---|
| | 108 | matrix.createGradientBox(fireW,fireH,Math.PI/2,-fireW/2,-fireH*(focalPointRatio+1)/2); |
|---|
| | 109 | var colors:Array = [fireColorIn, fireColorOut, fireColorOut]; |
|---|
| | 110 | var alphas:Array = [1,1,0]; |
|---|
| | 111 | var ratios:Array = [30, 100, 220]; |
|---|
| | 112 | |
|---|
| | 113 | ball.graphics.clear(); |
|---|
| | 114 | ball.graphics.beginGradientFill(GradientType.RADIAL,colors, alphas, ratios, matrix,"pad","rgb",focalPointRatio); |
|---|
| | 115 | ball.graphics.drawEllipse(-fireW/2,-fireH*(focalPointRatio+1)/2,fireW,fireH); |
|---|
| | 116 | ball.graphics.endFill(); |
|---|
| | 117 | //余白確保用透明矩形 |
|---|
| | 118 | ball.graphics.beginFill(0x000000,0); |
|---|
| | 119 | ball.graphics.drawRect(-fireW/2,0,fireW+margin,1); |
|---|
| | 120 | ball.graphics.endFill(); |
|---|
| | 121 | |
|---|
| | 122 | //ゆらぎ用のBitmap(ステージに貼付ける必要はないのでBitmapに貼る必要はない) |
|---|
| | 123 | displaceImage = new BitmapData(fireW+margin,fireH,false,0xFFFFFFFF); |
|---|
| | 124 | //火の芯付近の揺らぎを抑える用のグラデーション |
|---|
| | 125 | var matrix2:Matrix = new Matrix(); |
|---|
| | 126 | matrix2.createGradientBox(fireW+margin,fireH,Math.PI/2,0,0); |
|---|
| | 127 | var gradient_mc:Sprite = new Sprite; |
|---|
| | 128 | gradient_mc.graphics.beginGradientFill(GradientType.LINEAR,[0x666666,0x666666], [0,1], [120,220], matrix2); |
|---|
| | 129 | gradient_mc.graphics.drawRect(0,0,fireW+margin,fireH);//drawのターゲットなので生成位置にこだわる必要はない。 |
|---|
| | 130 | gradient_mc.graphics.endFill(); |
|---|
| | 131 | gradientImage = new BitmapData(fireW+margin,fireH,true,0x00FFFFFF); |
|---|
| | 132 | gradientImage.draw(gradient_mc);//gradient_mcを消す必要は? |
|---|
| | 133 | //同サイズの炎の揺らぎをランダム化 |
|---|
| | 134 | rdm = Math.floor(Math.random()*10); |
|---|
| | 135 | } |
|---|