※現在、「wonderfl build flash online」求人コンテンツ制作に関してのアンケートを実施中です!みなさまのお力添えを頂いて、続々とアンケート結果が集まっていますが、まだまだ募集しております。ご協力のほど、どうぞよろしくお願いいたします!

wonderfl運営事務局
→アンケートページ(※ログインしてからお答えいただけるようになっています。)

 notice: Flash editor updated! Join the development! Thanks to MiniBuilder


forked from : o8que's 朝青龍ゲーム [diff(78)]

FORKED

Slot Machine Rendering f.f.: 朝青龍ゲーム forked from: Slot Machine Rendering f.f.: 朝青龍ゲーム [diff(1)]

  1. // forked from keim_at_Si's Slot Machine Rendering f.f.: 朝青龍ゲーム
  2. // forked from o8que's 朝青龍ゲーム
  3. // リール回転+モーションブラー
  4. /* -------------------------------------------------------------------
  5.  * いきおいで作ってしまった。反省はしていない。
  6.  * 
  7.  * [inspired by]
  8.  * 昼青龍「朝青龍がやられたようだな・・・」:アルファルファモザイク
  9.  * http://alfalfalfa.com/archives/384861.html
  10.  * -------------------------------------------------------------------
  11.  * [遊び方]
  12.  * 真ん中のボタンをクリックして朝青龍を完成させてください。
  13.  * (完成しても何も起きませんが、気持ちいいと思います)
  14.  * -------------------------------------------------------------------
  15.  * [いじりどころ]
  16.  * SLOT_TEXTの中身を変えるだけで自分だけのスロットマシーンを作れます。
  17.  * -------------------------------------------------------------------
  18.  */
  19. package {
  20.     import com.bit101.components.PushButton;
  21.     import flash.display.Sprite;
  22.     import flash.events.Event;
  23.     
  24.     public class MorningBlueDragon extends Sprite {
  25.         public static const SLOT_NUM:int = 3;
  26.         public static const SLOT_SIZE:int = 140;
  27.         private static const SLOT_TEXT:Array = 
  28.         [["朝""昼""夕""夜"],
  29.          ["青""白""朱""玄"],
  30.          ["龍""虎""雀""武"]];
  31.         private var _slots:Array;
  32.         private var _stopped:int;
  33.         
  34.         public function MorningBlueDragon() {
  35.             _slots = [];
  36.             for (var i:int = 0; i < SLOT_NUM; i++) {
  37.                 var slot:Slot = new Slot((i * SLOT_SIZE) + 1010);
  38.                 slot.setTextList(SLOT_TEXT[i]);
  39.                 _slots.push(slot);
  40.                 addChild(slot);
  41.             }
  42.             new PushButton(this, SLOT_SIZE + 30, SLOT_SIZE + 20"click!", clickButton);
  43.             addEventListener(Event.ENTER_FRAME, update);
  44.         }
  45.         
  46.         private function clickButton(e:Event):void {
  47.             if (_stopped == 3for (var i:int=0; i<SLOT_NUM; i++) _slots[i].roll = true;
  48.             else _slots[_stopped].roll = false;
  49.         }
  50.         
  51.         private function update(e:Event):void {
  52.             _stopped = 0;
  53.             for (var i:int=0; i<SLOT_NUM; i++) _stopped += _slots[i].update();
  54.         }
  55.     }
  56. }
  57. import flash.display.*;
  58. import flash.filters.*;
  59. import flash.events.*;
  60. import flash.geom.*;
  61. import flash.text.*;
  62. class Slot extends Sprite {
  63.     public var roll:Boolean;
  64.     private var _list:Vector.<BitmapData> = new Vector.<BitmapData>();
  65.     private var _screen:BitmapData;
  66.     private var _index:Number, _vel:Number;
  67.     private var _pt:Point = new Point(00);
  68.     private var _blur:BlurFilter = new BlurFilter(116);
  69.     
  70.     public function Slot(posx:int, posy:int) {
  71.         var size:int = MorningBlueDragon.SLOT_SIZE;
  72.         x = posx;
  73.         y = posy;
  74.         buttonMode = true;
  75.         graphics.lineStyle(2, 0x808080);
  76.         graphics.drawRect(0,0,size,size);
  77.         addChild(new Bitmap(_screen = new BitmapData(size, size, false, 0xffffff)));
  78.         addEventListener("click"function(e:Event) : void { roll = false; } );
  79.         _index = 0;
  80.         _vel = 0;
  81.         roll =    false;
  82.     }
  83.     
  84.     public function setTextList(texts:Array):void {
  85.         var tf:TextField = new TextField();
  86.         tf.defaultTextFormat = new TextFormat(null, _screen.width);
  87.         tf.width = tf.height = _screen.width;
  88.         _list.length = texts.length;
  89.         for (var i:int=0; i<texts.length; i++) {
  90.             tf.text = texts[i];
  91.             _list[i] = new BitmapData(_screen.width, _screen.height, true0);
  92.             _list[i].draw(tf, nullnew ColorTransform(1,1,1,0.4,(i==0)?255:0));
  93.         }
  94.     }
  95.     
  96.     public function update() : int {
  97.         var i0:int, i1:int, i:int;
  98.         _screen.fillRect(_screen.rect, 0xffffff);
  99.         for (i=0; i<6; i++) {
  100.             i0 = int(_index);
  101.             i1 = (i0+1) % _list.length;
  102.             _pt.y = (_index - i0) * _screen.height;
  103.             _screen.copyPixels(_list[i0], _screen.rect, _pt);
  104.             _pt.y -= _screen.height;
  105.             _screen.copyPixels(_list[i1], _screen.rect, _pt);
  106.             _index += _vel;
  107.             if (_index >= _list.length) _index -= _list.length;
  108.             _vel += (roll) ? 0.001 : -0.01;
  109.             if (_vel > 0.05) _vel = 0.05;
  110.             else if (_vel < 0) {
  111.                 _vel = 0;
  112.                 _index = int(_index+0.5) % _list.length;
  113.             }
  114.         }
  115.         if (_vel > 0.03) _screen.applyFilter(_screen, _screen.rect, _screen.rect.topLeft, _blur);
  116.         return (roll) ? 0 : 1;
  117.     }
  118. }
noswf
Get Adobe Flash Player