ご参加いただきありがとうございました!!
やっほーい!
参加していただいてありがとうございます!楽しんでいただけましたかー。
アニメーション素材をどういう風に料理してもらえるかという実験的な試みでしたが、
思ってた以上にうまく使いこなしていてAS×アニメーションの次の表現のアイディアをいただけました。
ありがとうございました!
Thank you for your participation!
Did you enjoy it?
Though it was experiment how animation materials can be utilized, but it was lot more than I could imagined before. Fortunately, I came up with some ideas of next AS x Animation expression. Thank you very much.
uwi
- // ワンコは犬ですから
- package {
- import flash.display.*;
- import flash.events.*;
- import flash.utils.*;
- import flash.net.*;
- import flash.system.*;
- import jp.progression.commands.*;
- import jp.progression.commands.lists.*;
- import jp.progression.commands.display.*;
- import jp.progression.commands.net.*;
- import jp.progression.commands.tweens.*;
- import jp.progression.events.*;
- import flash.text.*;
- // 背景とかインターフェースとか作り込む余裕がなかった。
- // いろいろやっつけすぎ。
- public class Amateur extends Sprite {
- public static var GRAPHICS_URL:String = "http://swf.wonderfl.net/static/assets/checkmate05/wancoAmateur.swf";
- public var stayMotion:MovieClip;
- public var jumpMotion:MovieClip;
- public var highJumpMotion:MovieClip;
- public var walkMotion:MovieClip;
- public var runMotion:MovieClip;
- public var squatMotion:MovieClip;
- public var questionMotion:MovieClip;
- public var exclamationMotion:MovieClip;
- public var heartMotion:MovieClip;
- public var poutMotion:MovieClip;
- public var starMotion:MovieClip;
- public var singMotion:MovieClip;
- public var sleepMotion:MovieClip;
- public var wakeMotion:MovieClip;
- public function Amateur(){
- super();
- stage.scaleMode = StageScaleMode.NO_SCALE;
- stage.align = StageAlign.TOP_LEFT;
- var com:SerialList = new SerialList();
- com.addCommand(
- new LoadSWF( new URLRequest( GRAPHICS_URL ) ),
- function():void {
- var loader:Loader = Loader( this.latestData );
- var domain:ApplicationDomain = loader.contentLoaderInfo.applicationDomain;
- stayMotion = new ( domain.getDefinition( "StayMotion" ) as Class );
- jumpMotion = new ( domain.getDefinition( "JumpMotion" ) as Class );
- highJumpMotion = new ( domain.getDefinition( "HighJumpMotion" ) as Class );
- walkMotion = new ( domain.getDefinition( "WalkMotion" ) as Class );
- runMotion = new ( domain.getDefinition( "RunMotion" ) as Class );
- squatMotion = new ( domain.getDefinition( "SquatMotion" ) as Class );
- questionMotion = new ( domain.getDefinition( "QuestionMotion" ) as Class );
- exclamationMotion = new ( domain.getDefinition( "ExclamationMotion" ) as Class );
- heartMotion = new ( domain.getDefinition( "HeartMotion" ) as Class );
- poutMotion = new ( domain.getDefinition( "PoutMotion" ) as Class );
- starMotion = new ( domain.getDefinition( "StarMotion" ) as Class );
- singMotion = new ( domain.getDefinition( "SingMotion" ) as Class );
- sleepMotion = new ( domain.getDefinition( "SleepMotion" ) as Class );
- wakeMotion = new ( domain.getDefinition( "WakeMotion" ) as Class );
- }
- );
- com.addEventListener(ExecuteEvent.EXECUTE_COMPLETE,onLoadSWF);
- com.execute();
- _tf = new TextField();
- addChild(_tf);
- _tf.width = 200;
- _tf.height = 100;
- var g : Graphics = graphics;
- g.lineStyle(4, 0x111111);
- g.beginFill(0x993300);
- g.drawRect(-5, 250, 475, 250);
- g.endFill();
- g.beginFill(0x33aaff);
- g.drawRect(-5, -10, 475, 260);
- g.endFill();
- }
- private var _tf : TextField;
- private function onLoadSWF(e:Event):void {
- _motion = new Sprite();
- addChild(_motion);
- _mc = walkMotion;
- _motion.addChild(_mc);
- _motion.x = 465 / 2;
- _motion.y = 370;
- _motion.z = 0;
- addEventListener(Event.ENTER_FRAME, onEnterFrame);
- stage.addEventListener(MouseEvent.CLICK, onClick);
- this.mouseEnabled = true;
- _d = new Disc();
- addChild(_d);
- _state = 0;
- _rtx = _motion.x;
- _rtz = _motion.z;
- }
- private function onClick(e : MouseEvent) : void
- {
- if(_state == 0){
- _d.doThrowing();
- _t = 0;
- changeMotion(exclamationMotion);
- _state = 1;
- }else if(_state == 3){
- _d.init();
- changeMotion(walkMotion);
- _state = 0;
- _rtx = _motion.x;
- _rtz = _motion.z;
- }
- }
- private var _d : Disc;
- private var _motion : Sprite;
- private var _mc : MovieClip;
- // 0 : 投擲待ち
- // 1 : フリスビーを取りに行っている
- // 2 : フリスビーをくわえて戻っている
- // 3 : 戻った
- private var _state : int;
- private const RETX : Number = 465 / 2;
- private const RETZ : Number = 0;
- private var _t : int = -1;
- private var _tb : int = 0;
- private var _rtx : Number;
- private var _rtz : Number;
- private function onEnterFrame(e : Event) : void
- {
- if(_state == 0){
- if( (_motion.x - _rtx) * (_motion.x - _rtx) +
- (_motion.z - _rtz) * (_motion.z - _rtz) < 10 * 10){
- _rtx = Math.random() * 465;
- _rtz = Math.random() * 200;
- }
- moveWanko(_rtx, _rtz, 4);
- dirWanko(_motion.x + _prevX, _motion.z + _prevZ);
- }else if(_state == 1){
- _d.move();
- _t--;
- if(_t == -24){
- changeMotion(runMotion);
- }
- if(_t == _tb){
- _state = 2;
- return;
- }
- // _tf.text = "" + (_d.y - _d.vy * 13);
- dirWanko(_d.x, _d.z);
- if(_t < -24){
- moveWanko(_d.x, _d.z, 7);
- var d2 : Number =
- (_motion.x - _d.x) * (_motion.x - _d.x) +
- (_motion.z - _d.z) * (_motion.z - _d.z);
- if(_d.vy < 0 && Math.abs(_d.y - _d.vy * 13 - (350 - 165)) < 10 && d2 < 20 * 20){
- _t = 27;
- _tb = 14;
- changeMotion(highJumpMotion);
- return;
- }
- if(_d.y >= 350 && d2 < 30 * 30){
- _state = 2;
- }
- }
- }else if(_state == 2){
- _t--;
- var at : Number = dirWanko(RETX, RETZ);
- if(_t == 0){
- changeMotion(runMotion);
- }
- if(_t > 0){
- // _tf.appendText("" + _t + "\t" + _mc.currentFrame + "\n");
- _d.y = 360 - _t * 13;
- }else{
- moveWanko(RETX, RETZ, 7);
- _d.y = 350;
- _d.y += [0, 6, 0, -6, -6, 6][_mc.currentFrame]; // runMotionと同期
- }
- _d.x = _motion.x + 30 * Math.cos(at);
- _d.z = _motion.z + 30 * Math.sin(at);
- _d.rotationY = 0;
- _d.rotationX = -75;
- if( (_motion.x - RETX) * (_motion.x - RETX) +
- (_motion.z - RETZ) * (_motion.z - RETZ)
- < 10 * 10){
- changeMotion(MovieClip(selectR([wakeMotion, heartMotion, starMotion])));
- dirWanko(RETX, RETZ);
- _d.y = 360;
- _state = 3;
- }
- }else if(_state == 3){
- }
- // Z-sort
- if(getChildAt(1).z < getChildAt(2).z){
- swapChildrenAt(1, 2);
- }
- }
- private function selectR(a : Array) : Object
- {
- return a[int(Math.random() * a.length)];
- }
- private function changeMotion(mc : MovieClip) : void
- {
- if(_mc === mc)return;
- _motion.removeChild(_mc);
- _mc = mc;
- _mc.gotoAndPlay(1);
- _motion.addChild(_mc);
- }
- // ワンコを(tx, tz)のほうに向ける
- private function dirWanko(tx : Number, tz : Number) : Number
- {
- var at : Number = Math.atan2(tz - _motion.z, tx - _motion.x);
- var t : Number = ((Math.PI / 2 + 2 * Math.PI / 20 * 2.5) + 2 * Math.PI + at) % (2 * Math.PI);
- // _tf.text = "" + _t + "\t" + int(t / (Math.PI * 2) * 20) + "\n";
- _mc.wc2.wc3.gotoAndStop(int(t / (Math.PI * 2) * 20));
- return at;
- }
- private var _prevX : Number = 0.0;
- private var _prevZ : Number = -1.0;
- // ワンコを(tx, tz)のほうに動かす。
- // 直前とくらべてあまりに向きの角が急すぎるときは一定角まで回転する。
- private function moveWanko(tx : Number, tz : Number, v : Number) : void
- {
- var mdr : Number = Math.sqrt(
- (tx - _motion.x) * (tx - _motion.x) +
- (tz - _motion.z) * (tz - _motion.z)
- );
- var dx : Number, dz : Number;
- if(mdr > 10){
- dx = (tx - _motion.x) / mdr;
- dz = (tz - _motion.z) / mdr;
- if(_prevX * dx + _prevZ * dz < Math.cos(20 * Math.PI / 180)){
- // 角度変化の上限
- var sgn : Number = _prevX * dz - _prevZ * dx;
- var nc : Number = Math.cos(20 * Math.PI / 180);
- var ns : Number = Math.sin(20 * Math.PI / 180);
- var nz : Number = _prevZ * nc + _prevX * ns * (sgn > 0 ? 1 : -1);
- var nx : Number = _prevX * nc + _prevZ * ns * (sgn > 0 ? -1 : 1);
- dx = nx;
- dz = nz;
- }
- _prevX = dx;
- _prevZ = dz;
- }else{
- dx = 0;
- dz = 0;
- }
- // 等速移動
- _motion.x += dx * v;
- _motion.z += dz * v;
- }
- }
- }
- import flash.display.*;
- import flash.geom.*;
- class Disc extends Sprite
- {
- private const R : Number = 30;
- public var vxz : Number;
- public var vy : Number;
- public var dir : Number;
- public var vdir : Number;
- public var omega : Number; // フリスビーの回転角速度(揚力以外の移動には関係ない)
- public function Disc()
- {
- var mat : Matrix = new Matrix();
- mat.scale(1/1638*R*2, 1/1638*R*2);
- var g : Graphics = this.graphics;
- g.lineStyle(1, 0x000000);
- g.beginGradientFill(GradientType.RADIAL, [0x00ee00, 0x005500], [1, 1], [225, 255], mat);
- g.drawCircle(0, 0, R);
- g.endFill();
- // g.beginGradientFill(GradientType.RADIAL, [0x00ee00, 0x005500], [1, 1], [200, 255], mat);
- g.beginFill(0x00ee00);
- g.drawCircle(0, 0, 0.9 * R);
- g.endFill();
- g.beginFill(0x00ff00);
- g.drawCircle(0, 0, 0.5 * R);
- g.moveTo(0, 0);
- g.lineTo(0, 0.5 * R);
- this.rotationX = -90;
- makeBound(16);
- init();
- }
- private function makeBound(n : int) : void
- {
- var L : Number = R * Math.sin(Math.PI / n);
- for(var i : int = 0;i < n;i++){
- var theta : Number = Math.PI * 2 / n * i;
- var s : Shape = new Shape();
- var g : Graphics = s.graphics;
- g.lineStyle(1, 0x005500 + 0x001100 * (i % 2));
- g.beginFill(0x005500 + 0x001100 * (i % 2));
- g.drawRect(-L, 0, 2 * L, 3);
- g.endFill();
- s.x = R * Math.cos(theta);
- s.y = R * Math.sin(theta);
- s.rotationX = 90;
- s.rotationZ = 90+theta / Math.PI * 180;
- addChild(s);
- }
- }
- public function init() : void
- {
- x = 465 / 2;
- y = 120;
- z = -200;
- rotationX = -90;
- rotationZ = 0;
- rotationY = 0;
- }
- public function doThrowing() : void
- {
- vxz = 9.0 + triRandom() * 2.0;
- vy = 1.0 + triRandom() * 1.5;
- omega = 50 + triRandom() * 20;
- vdir = triRandom() * 0.01;
- dir = -vdir * 5 + triRandom() * 0.1;
- rotationX = -90 + (Math.random() + Math.random()) * 15 - 15;
- }
- private static function triRandom() : Number
- {
- return Math.random() + Math.random() - 1;
- }
- private const T : Number = 0.1;
- private const SCALE : Number = 10;
- private const MU : Number = Math.pow(0.95, T);
- private const OMU : Number = Math.pow(0.7, T);
- private const G : Number = 9.8;
- // フリスビーを移動
- public function move() : void
- {
- var theta : Number = Math.atan2(vy, vxz) / Math.PI * 180;
- var v2 : Number = vy * vy + vxz * vxz;
- // いんちき揚力
- var L : Number = (1.0 - 1 / omega) * vxz / Math.sqrt(v2);
- // 加速と減衰
- omega *= OMU;
- rotationY += omega;
- if(omega < 1.0)omega = 1.0;
- vxz *= MU;
- vy += (L - 1.0) * G * T * T;
- vy *= MU;
- // 飛行中だけ移動
- if(y < 350){
- x += vxz * Math.sin(dir) * T * SCALE;
- z += vxz * Math.cos(dir) * T * SCALE;
- y -= vy * T * SCALE;
- dir += vdir;
- }
- }
- }
- 出題者からのコメント
- 細かい演出のおかげで遊んでいると愛着を感じてきます。ワンダフル!!
- Comments from King
- I am deeply attached to it while I'm playing this detailed flash. Wonderfl!
buccchi
- // forked from checkmate's Checkmate vol.5 Amateur
- /*
- * マウスで蝶を操作。犬が追いかけるよ!
- * 上:蝶を奥へ
- * 下:蝶を手前へ
- * 左:蝶を左へ
- * 右:蝶を右へ
- */
- package {
- import flash.display.*;
- import flash.events.Event;
- public class Amateur extends Sprite {
- private const FOCUS:Number = 400;
- private const WIDTH:Number = stage.stageWidth;
- private const HEIGHT:Number = stage.stageHeight;
- private const DIS_X:Number = stage.stageWidth*.5;
- private const DIS_Y:Number = 300;
- private var _butterfly:Hae;
- private var _wanco:Wanco;
- private var _shadow:Shadow;
- private var _camera:MyStatus;
- public function Amateur(){
- super();
- stage.scaleMode = StageScaleMode.NO_SCALE;
- stage.align = StageAlign.TOP_LEFT;
- _butterfly = new Hae(WIDTH, HEIGHT);
- addChild(_butterfly);
- _shadow = new Shadow(30);
- addChild(_shadow);
- _wanco = new Wanco(_butterfly);
- addChild(_wanco);
- _camera = new MyStatus(DIS_X, 50, -100);
- addChild(_camera);
- addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
- }
- private function onEnterFrameHandler(e:Event):void {
- //2.5Dに変換
- var ratio:Number;
- //蝶
- ratio = FOCUS / (_butterfly.myZ-_camera.myZ);
- _butterfly.x = (_camera.myX-_butterfly.myX) *ratio +DIS_X;
- _butterfly.y = (_camera.myY-_butterfly.myY) *ratio +DIS_Y;
- _butterfly.scaleX = _butterfly.scaleY = ratio;
- //犬
- ratio = FOCUS / (_wanco.myZ-_camera.myZ);
- _wanco.x = (_camera.myX-_wanco.myX) *ratio +DIS_X;
- _wanco.y = (_camera.myY-_wanco.myY) *ratio +DIS_Y;
- _wanco.scaleX = _wanco.scaleY = ratio;
- //影
- _shadow.x = _wanco.x;
- _shadow.y = (_camera.myY) *ratio +DIS_Y;
- _shadow.scaleX = ratio;
- _shadow.scaleY = ratio*ratio/10;
- }
- }
- }
- import flash.display.Sprite;
- import flash.events.Event;
- class MyStatus extends Sprite{
- public var myX:Number;
- public var myY:Number;
- public var myZ:Number;
- public function MyStatus(mX:Number=0, mY:Number=0, mZ:Number=0){
- myX = mX;
- myY = mY;
- myZ = mZ;
- }
- }
- //影
- class Shadow extends Sprite {
- public function Shadow(r:Number){
- graphics.beginFill(0xDDDDDD, 1);
- graphics.drawCircle(0, -30, r);
- }
- }
- //蝶
- class Hae extends MyStatus {
- private var _w:Number;
- private var _h:Number;
- private var _hane:Sprite;
- private var _rad:Number = 0; //回転角
- private var _radius:Number = 20; //回転半径
- private var _base:Object; //基準位置
- public function Hae(w:Number, h:Number){
- super();
- _w = w;
- _h = h;
- _base = {x:0, y:110, z:0};
- myY = _base.y;
- //蝶を描画
- _hane = new Sprite();
- _hane.graphics.beginFill(0x999999, 1);
- _hane.graphics.drawCircle(-2.5, -1, 2);
- _hane.graphics.beginFill(0x999999, 1);
- _hane.graphics.drawCircle(2.5, -1, 2);
- addChild(_hane);
- graphics.beginFill(0x000000, 1);
- graphics.drawCircle(0, 0, 1.5);
- //
- addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
- }
- private function onEnterFrameHandler(e:Event):void {
- _base.x += (_w-stage.mouseX-myX)*.1;
- _base.z += (_h*2-stage.mouseY*2-myZ)*.1;
- _rad = (_rad <= 0)? _rad-.15+(Math.PI*2) : _rad-.15;
- myX = _base.x + Math.cos(_rad)*_radius;
- myZ = _base.z + Math.sin(_rad)*_radius;
- //はばたきアニメーション
- _hane.alpha = (_hane.alpha==1)? .4 : 1;
- }
- }
- import flash.display.*;
- import flash.events.*;
- import flash.utils.*;
- import flash.net.*;
- import flash.system.*;
- import jp.progression.commands.*;
- import jp.progression.commands.lists.*;
- import jp.progression.commands.display.*;
- import jp.progression.commands.net.*;
- import jp.progression.commands.tweens.*;
- import jp.progression.events.*;
- import org.libspark.betweenas3.BetweenAS3;
- import org.libspark.betweenas3.easing.*;
- import org.libspark.betweenas3.tweens.ITween;
- import org.libspark.betweenas3.events.TweenEvent;
- class Wanco extends MyStatus {
- public static var GRAPHICS_URL:String = "http://swf.wonderfl.net/static/assets/checkmate05/wancoAmateur.swf";
- private var stayMotion:MovieClip;
- private var _mark:MyStatus;
- private var _base:Object; //基準位置
- private var _local:Object; //ローカル位置
- public function Wanco(hae:MyStatus){
- super();
- _mark = hae;
- _base = {x:0, y:0, z:0};
- _local = {x:0, y:0, z:0};
- var com:SerialList = new SerialList();
- com.addCommand(
- new LoadSWF( new URLRequest( GRAPHICS_URL ) ),
- function():void {
- var loader:Loader = Loader( this.latestData );
- var domain:ApplicationDomain = loader.contentLoaderInfo.applicationDomain;
- stayMotion = new ( domain.getDefinition( "StayMotion" ) as Class );
- }
- );
- com.addEventListener(ExecuteEvent.EXECUTE_COMPLETE,onLoadSWF);
- com.execute();
- }
- private function onLoadSWF(e:Event):void {
- addChild(stayMotion as MovieClip);
- addEventListener(Event.ENTER_FRAME, onEnterFrameHandler);
- //ジャンプアニメーション設定
- var t:ITween = BetweenAS3.parallel(
- BetweenAS3.serial(
- BetweenAS3.tween(stayMotion, { scaleX:.8, scaleY:1.2 }, { scaleX:1.1, scaleY:.8 }, .25, Sine.easeOut),
- BetweenAS3.tween(stayMotion, { scaleX:1.1, scaleY:.8 }, null, .75, Sine.easeOutIn)
- ),
- BetweenAS3.serial(
- BetweenAS3.tween(_local, { y:50 }, null, .5, Sine.easeOut),
- BetweenAS3.tween(_local, { y:0 }, null, .5, Sine.easeIn)
- )
- );
- t = BetweenAS3.scale(t, .8);
- t.stopOnComplete = false;
- t.play();
- }
- private function onEnterFrameHandler(e:Event):void {
- _base.x += (_mark.myX-_base.x)*.05;
- _base.z += (_mark.myZ-_base.z)*.05;
- myX = _base.x;
- myY = _local.y;
- myZ = _base.z;
- //向き変更
- var myRotate:Number = Math.atan2(_base.x-_mark.myX, _base.z-_mark.myZ) *180 /Math.PI + 360+30;
- var frame:Number = Math.floor(myRotate%360/18)+1;
- stayMotion.wc2.wc3..gotoAndStop(frame);
- }
- }
- 出題者からのコメント
- 「蠅だろ!!」と思った時点で負けですね。
動きも好きですがタイトルにやられました。
- Comments from King
- "Is it a fly?" No, you are wrong.
Of course movement is well done but I like the title.
osamX
- // forked from checkmate's Checkmate vol.5 Amateur
- /**
- * 遊び方:
- * 1. フルスクリーンにします。
- * 2. マウスが右向きになるように置きます。
- * 3. マウスを左手で押さえます。
- * 4. 右手をマウスホイールの上に置き、左右に動かします。
- * 5. 左クリック、ホイールクリックしてみると...?
- *
- * ヒント:
- * ホイールクリック3回
- *
- * ソースはメッチャクチャのグッチャグチャ。あんまり見ないでね。
- * http://flash-scope.com/?p=709
- */
- package {
- import flash.display.*;
- import flash.events.*;
- import flash.utils.*;
- import flash.net.*;
- import flash.system.*;
- import jp.progression.commands.*;
- import jp.progression.commands.lists.*;
- import jp.progression.commands.display.*;
- import jp.progression.commands.net.*;
- import jp.progression.commands.tweens.*;
- import jp.progression.events.*;
- import org.libspark.betweenas3.BetweenAS3;
- import org.libspark.betweenas3.easing.*;
- import org.libspark.betweenas3.tweens.ITween;
- import org.libspark.betweenas3.events.TweenEvent;
- import flash.system.Security;
- public class Nadenade extends Sprite {
- public static var GRAPHICS_URL:String = "http://swf.wonderfl.net/static/assets/checkmate05/wancoProfessional.swf";
- public var stayMotion:MovieClip;
- public var jumpMotion:MovieClip;
- public var highJumpMotion:MovieClip;
- public var walkMotion:MovieClip;
- public var runMotion:MovieClip;
- public var squatMotion:MovieClip;
- public var questionMotion:MovieClip;
- public var exclamationMotion:MovieClip;
- public var heartMotion:MovieClip;
- public var poutMotion:MovieClip;
- public var starMotion:MovieClip;
- public var singMotion:MovieClip;
- public var sleepMotion:MovieClip;
- public var wakeMotion:MovieClip;
- private const SIZE:uint = 465;
- private var hand:MyHand;
- private var lc:LocalConnectionEx;
- private var motionList:Array;
- private var guchaflg:Boolean = false;
- private var singflg:Boolean = false;
- private var achaflg:Boolean = false;
- private var eraseflg:Boolean = false;
- private var lastAchaTime:int;
- private const NUM:uint = 20;
- private var particles:Array = [];
- private var fragments:Array = [];
- private const HX:Number = 0;
- private const HY:Number = 50;
- public function Nadenade () {
- super();
- //Security.allowDomain("flash-scope.com");
- stage.scaleMode = StageScaleMode.NO_SCALE;
- stage.align = StageAlign.TOP_LEFT;
- var com:SerialList = new SerialList();
- com.addCommand(
- new LoadSWF( new URLRequest( GRAPHICS_URL ) ),
- function():void {
- var loader:Loader = Loader( this.latestData );
- var domain:ApplicationDomain = loader.contentLoaderInfo.applicationDomain;
- stayMotion = new ( domain.getDefinition( "StayMotion" ) as Class );
- jumpMotion = new ( domain.getDefinition( "JumpMotion" ) as Class );
- highJumpMotion = new ( domain.getDefinition( "HighJumpMotion" ) as Class );
- walkMotion = new ( domain.getDefinition( "WalkMotion" ) as Class );
- runMotion = new ( domain.getDefinition( "RunMotion" ) as Class );
- squatMotion = new ( domain.getDefinition( "SquatMotion" ) as Class );
- questionMotion = new ( domain.getDefinition( "QuestionMotion" ) as Class );
- exclamationMotion = new ( domain.getDefinition( "ExclamationMotion" ) as Class );
- heartMotion = new ( domain.getDefinition( "HeartMotion" ) as Class );
- poutMotion = new ( domain.getDefinition( "PoutMotion" ) as Class );
- starMotion = new ( domain.getDefinition( "StarMotion" ) as Class );
- singMotion = new ( domain.getDefinition( "SingMotion" ) as Class );
- sleepMotion = new ( domain.getDefinition( "SleepMotion" ) as Class );
- wakeMotion = new ( domain.getDefinition( "WakeMotion" ) as Class );
- },
- hand = new MyHand()
- );
- com.addEventListener(ExecuteEvent.EXECUTE_COMPLETE,onLoadSWF);
- com.execute();
- }
- private function onLoadSWF(e:Event):void {
- motionList = [
- stayMotion, //0
- walkMotion, //1
- runMotion, //2
- squatMotion, //3
- questionMotion, //4
- exclamationMotion,//5
- heartMotion, //6
- poutMotion, //7
- singMotion, //8
- sleepMotion, //9
- wakeMotion //10
- ];
- for each( var motion:MovieClip in motionList ) {
- addChild(motion);
- motion.x = SIZE / 2;
- motion.y = SIZE / 2 + 100;
- motion.scaleX = motion.scaleY = 3;
- }
- freeMotion();
- hand.x = HX;
- hand.y = HY;
- hand.alpha = 0;
- addChild(hand);
- var handframe:int = 0;
- var cnt:int = 0;
- var lastNadeTime:int;
- const SPEED:uint = 2;
- var buruburu:Boolean = false;
- stage.addEventListener(MouseEvent.MOUSE_WHEEL, function(e:MouseEvent):void {
- resetHand();
- eraseflg = true;
- if (!singflg && !guchaflg && !achaflg) {
- if (e.delta > 0) cnt++;
- else if (e.delta < 0) cnt--;
- if (Math.abs(cnt) >= SPEED) {
- handframe += int(cnt / SPEED);
- cnt = 0;
- if (handframe < 0) handframe = 0;
- else if (handframe > 4) handframe = 4;
- }
- hand.show(handframe);
- hand.alpha = 0.6;
- lastNadeTime = getTimer();
- showMotion(6);
- }
- });
- var tim:uint = 0;
- addEventListener(Event.ENTER_FRAME, function(e:Event):void {
- if (++tim % 2 == 0) {
- tim = 0;
- if (!achaflg && !guchaflg && hand.alpha > 0 && getTimer() - lastNadeTime > 500) {
- eraseflg = true;
- hand.alpha -= 0.1;
- if (hand.alpha <= 0) {
- eraseflg = false;
- freeMotion();
- }
- }
- if (achaflg) {
- buruburu = !buruburu;
- if (buruburu) hand.x = HX + 10;
- else hand.x = HX;
- }
- }
- for (var i:uint = 0; i < particles.length; i++) {
- var p:Particle = particles[i];
- if(p && p.y < 500){
- p.vy += 1.5;
- p.vx *= 0.987;
- p.vy *= 0.987;
- p.x += p.vx;
- p.y += p.vy;
- fragments[i].x = p.x;
- fragments[i].y = p.y;
- }else if(fragments[i]){
- removeChild(fragments[i]);
- fragments[i] = null;
- particles[i] = null;
- }
- }
- });
- wheelClickHandler();
- }
- private function wheelClickHandler():void {
- var loader:Loader = new Loader();
- var request:URLRequest = new URLRequest("http://flash-scope.com/wonderfl/ClickTest/mouse.swf");
- loader.load(request);
- lc = new LocalConnectionEx();
- lc.allowDomain('*');
- lc.connect("_wonderflconnection");
- var frame:int = 1;
- var guchaNum:uint = 0;
- lc.leftDown = function():void {
- resetHand();
- if (!singflg && !guchaflg && !achaflg && !eraseflg) {
- showMotion(8);
- addEventListener(Event.ENTER_FRAME, function(e:Event):void {
- if (!singflg) { //do once
- singMotion.gotoAndPlay(1);
- singMotion.wc2.wc3.gotoAndPlay(2);
- singflg = true;
- }
- frame++;
- if (frame > 31) {
- singflg = false;
- frame = 1;
- singMotion.stop();
- removeEventListener(Event.ENTER_FRAME, arguments.callee);
- freeMotion();
- }
- });
- }
- };
- lc.wheelDown = function():void {
- resetHand();
- if (!singflg && !guchaflg && !achaflg) {
- showMotion(10);
- guchaflg = true;
- hand.alpha = 0.6;
- BetweenAS3.parallel(
- BetweenAS3.tween(hand, {y:120},null,0.1),
- BetweenAS3.tween(wakeMotion, { height:50, width:250 }, null, 0.3, Back.easeOutWith(5.0))
- ).play();
- createFragment();
- }
- };
- lc.wheelUp = function():void {
- if(!singflg && guchaflg && !achaflg){
- var tween:ITween = BetweenAS3.tween(wakeMotion, { height:55.8 * 3, width:60.45 * 3 }, null, 0.5, Elastic.easeOut);
- tween.addEventListener(TweenEvent.COMPLETE, function(e:TweenEvent):void {
- freeMotion();
- guchaflg = false;
- eraseflg = false;
- if (++guchaNum >= 3) {
- lastAchaTime = getTimer();
- guchaNum = 0;
- hand.show(5);
- hand.alpha = 1;
- achaflg = true;
- showMotion(4);
- }
- });
- BetweenAS3.parallel(
- BetweenAS3.tween(hand, {y:HY},null,0.05),
- tween
- ).play();
- }
- };
- }
- private function showMotion(num:uint):void {
- var i:uint = 0;
- for each( var motion:MovieClip in motionList ) {
- if (i++ == num) {
- motion.visible = true;
- //motion.stop();
- }else {
- motion.visible = false;
- //motion.gotoAndPlay(1);
- }
- }
- }
- private function freeMotion():void {
- var num:uint = int(Math.random() * 8);
- switch(num) {
- case 6: num = 7; break;
- case 7: num = 9; break;
- }
- showMotion(num);
- }
- private function resetHand():void {
- if (achaflg && getTimer()-lastAchaTime>1000) {
- hand.x = HX;
- achaflg = false;
- eraseflg = false;
- hand.show(0);
- hand.alpha = 0;
- }
- }
- private function createFragment(e:MouseEvent = null):void {
- var l:uint = fragments.length;
- for (var i:uint = 0; i < NUM; i++) {
- var p:Particle = new Particle(465/2, 330, 40 * Math.random()-20, -20 * Math.random());
- particles.push(p);
- var s:Sprite = new Sprite();
- s.graphics.lineStyle(5, 0x330000);
- s.graphics.beginFill(0xCC6633);
- //s.graphics.beginFill(0xFFFFFF*Math.random());
- s.graphics.drawCircle(0, 0, 5);
- s.graphics.endFill();
- s.x = p.x;
- s.y = p.y;
- fragments.push(s);
- addChildAt(fragments[l + i],0);
- //addChild(fragments[l + i]);
- }
- }
- }
- }
- import flash.display.Loader;
- import flash.display.Sprite;
- import flash.net.URLRequest;
- import flash.system.LoaderContext;
- class MyHand extends Sprite
- {
- public var images:Array = [];
- public function MyHand():void
- {
- for (var i:uint = 1; i <= 6; i++){
- var loader:Loader = new Loader();
- loader.load(new URLRequest("http://flash-scope.com/wonderfl/Wanco/img"+i+".png"), new LoaderContext(true));
- images.push(loader);
- addChild(images[i - 1]);
- }
- show(0);
- }
- public function show(num:uint):void {
- for (var i:uint = 0; i < 6; i++) {
- if(i==num) images[i].visible = true;
- else images[i].visible = false;
- }
- }
- }
- class Particle
- {
- public var x:Number;
- public var y:Number;
- public var vx:Number;
- public var vy:Number;
- public function Particle(_x:Number, _y:Number,_vx:Number,_vy:Number):void {
- x = _x;
- y = _y;
- vx = _vx;
- vy = _vy;
- }
- }
- import flash.net.LocalConnection;
- dynamic class LocalConnectionEx extends LocalConnection
- {
- }
- 出題者からのコメント
- マウスホイールを使ってワンコをなでるというアイディアが良いですね。
ホイールを机に付けてコロコロやるとさらに臨場感がアップ!
※windowsでご覧ください
- Comments from King
- The idea using scroll wheel to play with Wanko is great.
Moreover, it become even more realistic by putting mouse on table.
*See more on Windows
uwi
- // forked from checkmate's Checkmate vol.5 Professenal
- // ワンコといえばワンコそば。いろんな動きをするワンコを捕まえて食べよう!
- // え、わんこはお椀のことだって?細かいことは( ゚ε゚)キニシナイ!!
- // 申し訳程度に音も出るよ
- package {
- import flash.display.*;
- import flash.events.*;
- import flash.geom.*;
- import flash.net.*;
- import flash.system.*;
- import flash.text.*;
- import flash.utils.*;
- import jp.progression.commands.*;
- import jp.progression.commands.lists.*;
- import jp.progression.commands.display.*;
- import jp.progression.commands.net.*;
- import jp.progression.commands.tweens.*;
- import jp.progression.events.*;
- import org.si.sion.*;
- [SWF(frameRate="30", backgroundColor="#aaaa55")]
- public class WankoSoba extends Sprite {
- public static var GRAPHICS_URL:String = "http://swf.wonderfl.net/static/assets/checkmate05/wancoProfessional.swf";
- public var stayMotion:MovieClip;
- public var jumpMotion:MovieClip;
- public var highJumpMotion:MovieClip;
- public var walkMotion:MovieClip;
- public var runMotion:MovieClip;
- public var squatMotion:MovieClip;
- public var questionMotion:MovieClip;
- public var exclamationMotion:MovieClip;
- public var heartMotion:MovieClip;
- public var poutMotion:MovieClip;
- public var starMotion:MovieClip;
- public var singMotion:MovieClip;
- public var sleepMotion:MovieClip;
- public var wakeMotion:MovieClip;
- public function WankoSoba(){
- super();
- stage.scaleMode = StageScaleMode.NO_SCALE;
- stage.align = StageAlign.TOP_LEFT;
- Wonderfl.capture_delay(5);
- var com:SerialList = new SerialList();
- com.addCommand(
- new LoadSWF( new URLRequest( GRAPHICS_URL ) ),
- function():void {
- var loader:Loader = Loader( this.latestData );
- var domain:ApplicationDomain = loader.contentLoaderInfo.applicationDomain;
- stayMotion = new ( domain.getDefinition( "StayMotion" ) as Class );
- jumpMotion = new ( domain.getDefinition( "JumpMotion" ) as Class );
- highJumpMotion = new ( domain.getDefinition( "HighJumpMotion" ) as Class );
- walkMotion = new ( domain.getDefinition( "WalkMotion" ) as Class );
- runMotion = new ( domain.getDefinition( "RunMotion" ) as Class );
- squatMotion = new ( domain.getDefinition( "SquatMotion" ) as Class );
- questionMotion = new ( domain.getDefinition( "QuestionMotion" ) as Class );
- exclamationMotion = new ( domain.getDefinition( "ExclamationMotion" ) as Class );
- heartMotion = new ( domain.getDefinition( "HeartMotion" ) as Class );
- poutMotion = new ( domain.getDefinition( "PoutMotion" ) as Class );
- starMotion = new ( domain.getDefinition( "StarMotion" ) as Class );
- singMotion = new ( domain.getDefinition( "SingMotion" ) as Class );
- sleepMotion = new ( domain.getDefinition( "SleepMotion" ) as Class );
- wakeMotion = new ( domain.getDefinition( "WakeMotion" ) as Class );
- }
- );
- // お椀を描く
- var mat : Matrix = new Matrix();
- mat.scale(1/1638*465/2* 2, 1/1638*465/2*RATIO*2);
- mat.translate(465 / 2, 280);
- graphics.lineStyle(2, 0x000000);
- graphics.beginGradientFill(GradientType.RADIAL, [0xaa0000, 0x440000], [1, 1], [100, 255], mat);
- var W : Number = 465 * 0.4;
- graphics.drawEllipse(465/2 - W, 250 - W * RATIO, W * 2, W * RATIO * 2);
- _sd = new SiONDriver();
- _tf = new TextField();
- addChild(_tf);
- _tfScore = new TextField();
- _tfScore.autoSize = "left";
- _tfScore.defaultTextFormat = new TextFormat("fantasy", 30);
- _tfScore.selectable = false;
- addChild(_tfScore);
- _tfTime = new TextField();
- _tfTime.autoSize = "right";
- _tfTime.x = 465;
- _tfTime.defaultTextFormat = new TextFormat("fantasy", 30);
- _tfTime.selectable = false;
- addChild(_tfTime);
- _tfStart = new TextField();
- _tfStart.autoSize = "center";
- _tfStart.x = 465 / 2;
- _tfStart.y = 420;
- _tfStart.defaultTextFormat = new TextFormat("fantasy", 40, 0xffdd33);
- _tfStart.text = " START ";
- _tfStart.background = true;
- _tfStart.backgroundColor = 0x773333;
- _tfStart.selectable = false;
- addChild(_tfStart);
- com.addEventListener(ExecuteEvent.EXECUTE_COMPLETE,onLoadSWF);
- com.execute();
- }
- private const RATIO : Number = 200 / (465 / 2.0);
- private var _tf : TextField; // デバッグ用
- private var _tfScore : TextField; // スコア表示
- private var _tfTime : TextField; // 残り時間表示
- private var _tfStart : TextField; // スタートボタン
- private var _sd : SiONDriver;
- private const LIMTIME : int = 30 * 1000; // 時間制限
- private var _endTime : int;
- private var _sobaClips : Array; // モーション配列
- private var _sobaKind : int;
- // 0 :
- // 1 : 落下中
- // 2 : 回転中
- private var _state : int;
- private var _frameCount : int;
- private var _score : int;
- private var _soba : MovieClip;
- private function onLoadSWF(e:Event):void {
- _sobaClips = [
- stayMotion, jumpMotion, highJumpMotion,
- walkMotion, runMotion, squatMotion,
- questionMotion, exclamationMotion, heartMotion,
- poutMotion, starMotion, singMotion,
- sleepMotion
- ];
- _tfStart.addEventListener(MouseEvent.CLICK, onStart);
- }
- private function onStart(e : MouseEvent) : void
- {
- initGame();
- }
- private function initGame() : void
- {
- _tfStart.visible = false;
- _score = 0;
- _endTime = getTimer() + LIMTIME;
- _tfScore.text = "スコア : " + 0 + "杯\n";
- appendSoba();
- }
- private function endGame() : void
- {
- removeSoba();
- _tfStart.visible = true;
- _state = 0;
- }
- private function appendSoba() : void
- {
- _sobaKind = Math.random() * _sobaClips.length;
- _soba = _sobaClips[_sobaKind];
- _soba.x = 0;
- _soba.y = 0;
- _soba.z = -400;
- _soba.r = 465 * 0.3 * (1.0 - Math.random() * Math.random());
- _soba.theta = Math.random() * 2 * Math.PI;
- _soba.omega = Math.random() * 0.4 - 0.2;
- if(_soba === runMotion){
- _soba.omega = Math.random() * 1.2 - 0.6;
- }
- _soba.vz = 25;
- _soba.gotoAndStop(1);
- addChild(_soba);
- addEventListener(Event.ENTER_FRAME, onEnterFrame);
- _frameCount++;
- _state = 1;
- }
- private function removeSoba() : void
- {
- _soba.removeEventListener(MouseEvent.MOUSE_DOWN, onSobaMouseDown);
- _soba.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
- removeChild(_soba);
- }
- private function onEnterFrame(e : Event) : void
- {
- _frameCount++;
- if(_state == 1){
- // 落下
- _soba.vz += 2;
- _soba.z += _soba.vz;
- if(_soba.z > 0){
- _soba.z = 0;
- _soba.play();
- _state = 2;
- _frameCount = 0;
- // star:n体分身
- if(_soba == starMotion){
- _soba.nBody = int(Math.random() * 4) + 2;
- }
- _soba.addEventListener(MouseEvent.MOUSE_DOWN, onSobaMouseDown);
- return;
- }
- }else{
- // 回転
- _soba.r *= 0.98;
- _soba.omega *= 0.98;
- _soba.theta += _soba.omega;
- // question:ワープ
- if(_soba == questionMotion && _frameCount % 15 == 0){
- _soba.theta = Math.random() * Math.PI * 2;
- }
- // exclamation:とびあがる
- if(_soba == exclamationMotion){
- if(_soba.z == 0 && _soba.hitTestPoint(mouseX, mouseY, true)){
- _soba.vz = -70;
- _soba.z += _soba.vz;
- }else{
- if(_soba.z != 0){
- _soba.vz+=7;
- _soba.z += _soba.vz;
- if(_soba.z > 0)_soba.z = 0;
- }
- }
- }
- // exclamation:逃げる
- if(_soba == sleepMotion){
- if(Math.abs(_soba.omega) < 0.1 && _soba.hitTestPoint(mouseX, mouseY, true)){
- _soba.omega = Math.random() < 0.5 ? 0.4 : -0.4;
- }
- }
- // sing:再加速
- if(_soba == singMotion && _frameCount % 10 == 0){
- _soba.omega = Math.random() * 0.8 - 0.4;
- }
- // star:n体分身
- if(_soba == starMotion){
- _soba.omega = 6.28 / _soba.nBody;
- }
- // pout:小さくなる
- if(_soba == poutMotion){
- var scale : Number = (2 + Math.cos(_frameCount * 10 / 180 * 3.14)) / 3;
- _soba.scaleX = scale;
- _soba.scaleY = scale;
- }
- // heart:外側に移動する
- if(_soba == heartMotion){
- _soba.r *= Math.pow(465 / 3 / _soba.r, 1 / 4);
- }
- // squat:その場に止まる
- if(_soba == squatMotion){
- _soba.r /= 0.98;
- _soba.omega = 0;
- }
- // walk:角速度が減衰しない
- if(_soba == walkMotion){
- _soba.r /= 0.98;
- }
- }
- _soba.x = _soba.r * Math.cos(_soba.theta) + 465 / 2;
- _soba.y = _soba.r * Math.sin(_soba.theta) * RATIO + 250 + 20;
- turn(_soba);
- var leftTime : int = _endTime - getTimer();
- if(leftTime > 0){
- _tfTime.text = "残り " + int(leftTime / 1000) + "秒";
- }else{
- endGame();
- }
- }
- // ワンコが押されたとき
- private function onSobaMouseDown(e : MouseEvent) : void
- {
- _sd.play("%5 @5 t180l16o6ecec");
- _score++;
- _tfScore.text = "スコア : " + _score + "杯\n";
- removeSoba();
- appendSoba();
- }
- // マウスポインタの方を向く
- private function turn(m : MovieClip) : void
- {
- var y : Number = stage.mouseY - m.y;
- var x : Number = stage.mouseX - m.x;
- var t : Number = Math.atan(y / x);
- if(x < 0)t += Math.PI;
- t = ((Math.PI / 2 + 2 * Math.PI / 20 * 2.5) + 2 * Math.PI - t) % (2 * Math.PI);
- m.wc2.wc3.gotoAndStop(int(t / (Math.PI * 2) * 20));
- }
- }
- }
- 出題者からのコメント
- きっと誰かがやるんだろうなと思ったらやっちゃいましたね。
ちゃんと素材を有効利用していてゲームとして成立させているところがすばらしい!
- Comments from King
- I knew someone would do this.
But beauty of this piece is it work as a complete game, with given materials.
beinteractive
- package
- {
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.display.PixelSnapping;
- import flash.display.Sprite;
- import flash.display.StageAlign;
- import flash.display.StageQuality;
- import flash.display.StageScaleMode;
- import flash.display.Graphics;
- import flash.display.Loader;
- import flash.display.LoaderInfo;
- import flash.events.Event;
- import flash.events.KeyboardEvent;
- import flash.geom.ColorTransform;
- import flash.geom.Point;
- import flash.geom.Matrix;
- import flash.text.TextField;
- import flash.text.TextFieldAutoSize;
- import flash.text.TextFormat;
- import flash.net.URLRequest;
- import flash.ui.Keyboard;
- import com.bit101.components.Label;
- public class UnkoOrNot extends Sprite
- {
- private static var UNKO_URL:String = 'http://swf.wonderfl.net/static/assets/checkmate05/wancoProfessional.swf';
- private static const ZERO:Point = new Point(0, 0);
- private static const STATE_INPUT:uint = 0;
- private static const STATE_SHOT:uint = 1;
- private static const STATE_GAMEOVER:uint = 2;
- public function UnkoOrNot()
- {
- stage.scaleMode = StageScaleMode.NO_SCALE;
- stage.quality = StageQuality.MEDIUM;
- var loader:Loader = new Loader();
- loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteHandler);
- loader.load(new URLRequest(UNKO_URL));
- }
- private var _unkoClass:Class;
- private var _ballBackground:Sprite;
- private var _ballLayer:Sprite;
- private var _shotLayer:Sprite;
- private var _particleLayer:Sprite;
- private var _scoreField:Label;
- private var _titleField:Label;
- private var _shotBall:UnkoBall;
- private var _ballsBitmapData:BitmapData;
- private var _shotBitmapData:BitmapData;
- private var _ballsBitmapDataMatrix:Matrix;
- private var _shotAngle:Number;
- private var _shotAngleCounter:Number;
- private var _particles:Array = [];
- private var _isSpaceDown:Boolean = false;
- private var _nowState:uint;
- private var _score:int;
- private function loadCompleteHandler(e:Event):void
- {
- var loaderInfo:LoaderInfo = e.target as LoaderInfo;
- loaderInfo.removeEventListener(Event.COMPLETE, loadCompleteHandler);
- _unkoClass = loaderInfo.applicationDomain.getDefinition('WakeMotion') as Class;
- var sw:Number = stage.stageWidth;
- var sh:Number = stage.stageHeight;
- _ballBackground = new Sprite();
- _ballBackground.x = sw / 2;
- _ballBackground.y = sh / 2 - 80;
- _ballBackground.graphics.clear();
- _ballBackground.graphics.lineStyle(0, 0xcccccc);
- _ballBackground.graphics.drawCircle(0, 0, 100);
- addChild(_ballBackground);
- _ballLayer = new Sprite();
- _ballLayer.x = sw / 2;
- _ballLayer.y = sh / 2 - 80;
- addChild(_ballLayer);
- _shotLayer = new Sprite();
- addChild(_shotLayer);
- _particleLayer = new Sprite();
- addChild(_particleLayer);
- _ballsBitmapData = new BitmapData(sw, sh, true, 0x00000000);
- _ballsBitmapData.lock();
- _shotBitmapData = new BitmapData(sw, sh, true, 0x00000000);
- _shotBitmapData.lock();
- _ballsBitmapDataMatrix = new Matrix();
- _scoreField = new Label(this, 5, 3);
- _titleField = new Label(this, 0, 3, 'WANCO? OR NOT');
- _titleField.autoSize = true;
- new Label(this, 5, (sh - (21 + 14 * 3)), '[SPACEKEY]: SHOOT');
- new Label(this, 5, (sh - (21 + 14 * 2)), 'KATAMATTA: +20');
- new Label(this, 5, (sh - (21 + 14 * 1)), 'KATAMARANAI: -10');
- new Label(this, 5, (sh - (21 + 14 * 0)), 'HAMIDETA: GAMEOVER');
- startGame();
- stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
- stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
- addEventListener(Event.ENTER_FRAME, initialEnterFrameHandler);
- }
- private function initialEnterFrameHandler(e:Event):void
- {
- removeEventListener(Event.ENTER_FRAME, initialEnterFrameHandler);
- _titleField.x = stage.stageWidth - (_titleField.width + 5);
- addEventListener(Event.ENTER_FRAME, enterFrameHandler);
- }
- private function startGame():void
- {
- while (_ballLayer.numChildren > 0) {
- _ballLayer.removeChild(_ballLayer.getChildAt(0));
- }
- _ballLayer.addChild(new UnkoBall(40, _unkoClass));
- _shotBall = null;
- _score = 0;
- startInput();
- }
- private function startInput():void
- {
- _nowState = STATE_INPUT;
- _shotAngleCounter = 0;
- _shotBall = new UnkoBall(20, _unkoClass);
- _shotBall.x = stage.stageWidth / 2;
- _shotBall.y = stage.stageHeight - 30;
- _shotLayer.addChild(_shotBall);
- }
- private function keyDownHandler(e:KeyboardEvent):void
- {
- if (e.keyCode == Keyboard.SPACE) {
- _isSpaceDown = true;
- }
- }
- private function keyUpHandler(e:KeyboardEvent):void
- {
- if (e.keyCode == Keyboard.SPACE) {
- _isSpaceDown = false;
- }
- }
- private function enterFrameHandler(e:Event):void
- {
- updateParticles();
- if (_nowState == STATE_GAMEOVER) {
- _scoreField.text = 'GAMEOVER: ' + _score;
- if (_isSpaceDown) {
- _isSpaceDown = false;
- startGame();
- }
- return;
- }
- _ballLayer.rotation += 2;
- _ballBackground.rotation = _ballLayer.rotation;
- if (_nowState == STATE_INPUT) {
- var bx:Number = stage.stageWidth / 2;
- var by:Number = stage.stageHeight;
- _shotAngle = (150 - Math.sin(_shotAngleCounter) * 120) / 360 * Math.PI;
- _shotAngleCounter += Math.PI / 60;
- _shotBall.x = bx + Math.cos(_shotAngle) * 50;
- _shotBall.y = by - Math.sin(_shotAngle) * 50;
- _shotLayer.graphics.clear();
- _shotLayer.graphics.lineStyle(0, 0xcccccc);
- _shotLayer.graphics.drawCircle(bx, by, 50);
- _shotLayer.graphics.lineStyle(0, 0x333333);
- _shotLayer.graphics.moveTo(bx, by);
- _shotLayer.graphics.lineTo(_shotBall.x, _shotBall.y);
- if (_isSpaceDown) {
- _nowState = STATE_SHOT;
- _shotBall.positionX = _shotBall.x;
- _shotBall.positionY = _shotBall.y;
- _shotBall.velocityX = Math.cos(_shotAngle) * 18;
- _shotBall.velocityY = Math.sin(_shotAngle) * -18;
- }
- }
- if (_nowState == STATE_SHOT) {
- moveBall(_shotBall);
- _ballsBitmapDataMatrix.identity();
- _ballsBitmapDataMatrix.rotate(_ballLayer.rotation / 360 * Math.PI * 2);
- _ballsBitmapDataMatrix.translate(_ballLayer.x, _ballLayer.y);
- _ballsBitmapData.fillRect(_ballsBitmapData.rect, 0x00000000);
- _ballsBitmapData.draw(_ballLayer, _ballsBitmapDataMatrix);
- _shotBitmapData.fillRect(_shotBitmapData.rect, 0x00000000);
- _shotBitmapData.draw(_shotLayer);
- if (_ballsBitmapData.hitTest(ZERO, 128, _shotBitmapData, ZERO, 128)) {
- _shotLayer.removeChild(_shotBall);
- var r:Number = _shotBall.rotation;
- var p:Point = _ballLayer.globalToLocal(new Point(_shotBall.x, _shotBall.y));
- _shotBall.x = p.x;
- _shotBall.y = p.y;
- _ballLayer.addChild(_shotBall);
- _shotBall.rotation = r - _ballLayer.rotation;
- var l:Number = Math.sqrt(p.x * p.x + p.y * p.y);
- for (var i:uint = 0; i < 4; ++i) {
- var particle:UnkoBall = new UnkoBall(2 + Math.random() * 3, _shotBall.unkoClass);
- var ppos:Point = _ballLayer.localToGlobal(new Point(p.x * ((l - 10) / l), p.y * ((l - 10) / l)));
- particle.positionX = ppos.x;
- particle.positionY = ppos.y;
- particle.velocityX = (Math.random() * 16 + 2) - 9;
- particle.velocityY = Math.random() * -9 - 4;
- _particleLayer.addChild(particle);
- _particles.push(particle);
- }
- _score += 20;
- if (l > 90) {
- _nowState = STATE_GAMEOVER;
- _isSpaceDown = false;
- }
- else {
- startInput();
- }
- }
- if (_shotBall != null && isOut(_shotBall)) {
- _shotLayer.removeChild(_shotBall);
- _shotBall = null;
- _score -= 10;
- startInput();
- }
- }
- _scoreField.text = 'SCORE: ' + _score;
- }
- private function updateParticles():void
- {
- for (var i:int = 0; i < _particles.length; ++i) {
- var particle:UnkoBall = _particles[i] as UnkoBall;
- moveBall(particle);
- if (isOut(particle)) {
- _particleLayer.removeChild(particle);
- _particles.splice(i, 1);
- --i;
- }
- }
- }
- private function moveBall(ball:UnkoBall):void
- {
- ball.positionX += ball.velocityX;
- ball.positionY += ball.velocityY;
- ball.velocityY += 0.45;
- ball.rotation += 2;
- ball.x = ball.positionX;
- ball.y = ball.positionY;
- }
- private function isOut(ball:UnkoBall):Boolean
- {
- return ball.positionX < -30 || ball.positionX > stage.stageWidth + 30 || ball.positionY < -30 || ball.positionY > stage.stageHeight + 30;
- }
- }
- }
- import flash.display.Sprite;
- import flash.display.Graphics;
- import flash.display.MovieClip;
- import frocessing.color.ColorHSV;
- class UnkoBall extends Sprite
- {
- public function UnkoBall(size:Number, unkoClass:Class)
- {
- _unkoClass = unkoClass;
- var mc:MovieClip = new unkoClass();
- mc.width = size * 2;
- mc.scaleY = mc.scaleX;
- mc.y = mc.height / 2;
- mc.gotoAndPlay(1);
- addChild(mc);
- }
- private var _unkoClass:Class;
- public var positionX:Number = 0;
- public var positionY:Number = 0;
- public var velocityX:Number = 0;
- public var velocityY:Number = 0;
- public function get unkoClass():Class
- {
- return _unkoClass;
- }
- }
- 出題者からのコメント
- もうすこし素材の動きが欲しかったですが、ゲームとしては一番面白かったです!
- Comments from King
- Though I want a little more action of materials, it's the best game!
mex_takagi
- /**
- * ごく普通のワンコ掃除神経衰弱です。
- */
- package
- {
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.display.Sprite;
- import flash.display.MovieClip;
- import flash.display.Loader;
- import flash.events.Event;
- import flash.events.MouseEvent;
- import flash.filters.BlurFilter;
- import flash.net.URLRequest;
- import flash.system.ApplicationDomain;
- import flash.display.StageAlign;
- import flash.display.StageScaleMode;
- import flash.text.TextField;
- import flash.text.TextFormat;
- import org.libspark.betweenas3.BetweenAS3;
- import org.libspark.betweenas3.tweens.ITween;
- import org.libspark.betweenas3.events.TweenEvent;
- [SWF(backgroundColor="#FFFFFF", frameRate="30", width="465", height="465")]
- public class Unko extends Sprite
- {
- public static var GRAPHICS_URL:String = "http://swf.wonderfl.net/static/assets/checkmate05/wancoAmateur.swf";
- private var _motionArray:Array = ["StayMotion",
- "JumpMotion",
- "HighJumpMotion",
- "WalkMotion",
- "RunMotion",
- "SquatMotion",
- "QuestionMotion",
- "ExclamationMotion",
- "HeartMotion",
- "PoutMotion",
- "StarMotion",
- "SingMotion",
- "SleepMotion"];
- private var _domain:ApplicationDomain;
- private var _max:uint;
- private var _wankoArray:Array;
- private var _judgeArray:Array;
- private var _triggerArray:Array;
- private var _motionMCArray:Array;
- private var _combo:uint;
- private var _restCount:uint;
- private var _score:uint;
- private var _life:uint;
- private var _scoreField:TextField;
- private var _lifeField:TextField;
- private var _titleField:TextField;
- private var _catchField:TextField;
- private var _blur:BlurFilter;
- /**
- * constructor
- */
- public function Unko()
- {
- super();
- stage.scaleMode = StageScaleMode.NO_SCALE;
- stage.align = StageAlign.TOP_LEFT;
- Wonderfl.capture_delay(5);
- _judgeArray = new Array();
- _wankoArray = new Array();
- _triggerArray = new Array();
- _motionMCArray = new Array();
- _max = 20;
- _restCount = 20;
- _combo = 0;
- _score = 0;
- _life = 5;
- _blur = new BlurFilter(20, 20, 1);
- _titleField = createField(createFormat(24), "Let's ワンコ掃除");
- _titleField.x = 40;
- _titleField.y = 30;
- addChild(_titleField);
- _catchField = createField(createFormat(14), "神経衰弱の要領でワンコを掃除しろ!!!!!");
- _catchField.x = 40;
- _catchField.y = _titleField.y + _titleField.height + 10;
- addChild(_catchField);
- _scoreField = createField(createFormat(11), "SCORE:0");
- _scoreField.x = stage.stageWidth - _scoreField.width - 40;
- _scoreField.y = 30;
- addChild(_scoreField);
- _lifeField = createField(createFormat(11), "LIFE:5");
- _lifeField.x = stage.stageWidth - _lifeField.width - 40;
- _lifeField.y = 45;
- addChild(_lifeField);
- var loader:Loader = new Loader();
- loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHanlder);
- loader.load(new URLRequest(GRAPHICS_URL));
- }
- /**
- * ロード完了
- * @param event Event
- */
- private function onCompleteHanlder(event:Event):void
- {
- event.target.removeEventListener(Event.COMPLETE, onCompleteHanlder);
- _domain = event.target.applicationDomain;
- var hNum:int = 5;
- var cnt:int = 0;
- var i:uint = 0;
- for (i = 0; i < _max;i++ )
- {
- var temp:MovieClip = new ( _domain.getDefinition( _motionArray[0] ) as Class );
- temp.x = cnt % hNum * 80 + 70;
- temp.y = Math.floor(cnt / hNum) * 80 + 180;
- temp.id = String(i);
- temp.gotoAndStop(1);
- _triggerArray.push(temp);
- cnt++;
- }
- generateGame();
- }
- /**
- * ワンコ並べる
- */
- private function generateGame():void
- {
- var i:uint = 0;
- var rand:uint;
- var motionLen:uint = _motionArray.length;
- for (i = 0; i < _max / 2; i++ )
- {
- rand = Math.floor(Math.random() * motionLen);
- _wankoArray.push(_motionArray[rand]);
- _wankoArray.push(_motionArray[rand]);
- }
- //trace(_wankoArray);
- for (i = 0; i < _max;i++ )
- {
- var trigger:MovieClip = _triggerArray[i];
- addChild(trigger);
- rand = Math.floor(Math.random() * _wankoArray.length);
- var motion:MovieClip = new ( _domain.getDefinition( _wankoArray[rand] ) as Class );
- motion.type = _wankoArray[rand];
- motion.x = trigger.x;
- motion.y = trigger.y;
- motion.visible = false;
- addChild(motion);
- _motionMCArray.push(motion);
- trigger.targetMotion = motion;
- _wankoArray.splice(rand, 1);
- }
- addListener();
- }
- /**
- * addListener
- */
- private function addListener():void
- {
- for (var i:uint = 0; i < _max;i++ )
- {
- var trigger:MovieClip = _triggerArray[i];
- trigger.wc2.addEventListener( MouseEvent.CLICK, clickHandler);
- trigger.buttonMode = trigger.useHandCursor = true;
- }
- }
- /**
- * killListener
- */
- private function killListener():void
- {
- for (var i:uint = 0; i < _max;i++ )
- {
- var trigger:MovieClip = _triggerArray[i];
- trigger.wc2.removeEventListener( MouseEvent.CLICK, clickHandler);
- trigger.buttonMode = trigger.useHandCursor = false;
- }
- }
- /**
- * クリック時
- * @param event
- */
- public function clickHandler(event:MouseEvent):void
- {
- var motion:MovieClip = event.currentTarget.parent.targetMotion;
- motion.gotoAndPlay(1);
- motion.wc2.wc3.gotoAndPlay(2);
- event.currentTarget.parent.visible = false;
- motion.visible = true;
- var obj:Object = new Object();
- obj.trigger = event.currentTarget.parent;
- obj.motion = motion;
- //trace(motion.type);
- _judgeArray.push(obj);
- judge();
- }
- /**
- * スコアアップデート
- */
- private function updateScore():void
- {
- _scoreField.text = "SCORE:" + String(_score);
- _scoreField.x = stage.stageWidth - _scoreField.width - 40;
- }
- /**
- * ライフアップデート
- */
- private function updateLife():void
- {
- _lifeField.text = "LIFE:" + String(_life);
- _lifeField.x = stage.stageWidth - _lifeField.width - 40;
- }
- /**
- * ゲームオーバー
- */
- private function gameOver():void
- {
- //trace("Game Over");
- var _gameOver:Sprite = createGameOver();
- addChild(_gameOver);
- _gameOver.buttonMode = true;
- _gameOver.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void
- {
- _gameOver.buttonMode = false;
- _gameOver.removeEventListener(MouseEvent.CLICK, arguments.callee);
- removeChild(_gameOver);
- regenerate(true);
- });
- }
- /**
- * ゲーム終了時
- */
- private function regenerate(over:Boolean = false):void
- {
- var i:uint = 0;
- for (i = 0; i < _max;i++ )
- {
- _triggerArray[i].visible = true;
- if (contains(_motionMCArray[i])) removeChild(_motionMCArray[i]);
- }
- _restCount = 20;
- _wankoArray = [];
- generateGame();
- if (over)
- {
- _combo = 0;
- _score = 0;
- _life = 5;
- updateScore();
- updateLife();
- }
- }
- /**
- * 判定
- */
- private function judge():void
- {
- if (_judgeArray.length == 2)
- {
- killListener();
- var i:uint = 0;
- if (_judgeArray[0].motion.type == _judgeArray[1].motion.type)
- {
- //trace("あたり");
- _judgeArray[1].motion.wc2.wc3.addEventListener(Event.ENTER_FRAME, function(event:Event):void
- {
- _judgeArray[1].motion.wc2.wc3.nextFrame;
- if (_judgeArray[1].motion.wc2.wc3.currentFrame == _judgeArray[1].motion.wc2.wc3.totalFrames)
- {
- _judgeArray[1].motion.wc2.wc3.removeEventListener(Event.ENTER_FRAME, arguments.callee);
- for (i = 0; i < 2; i++)
- {
- _judgeArray[i].trigger.visible = true;
- _judgeArray[i].motion.visible = false;
- _judgeArray[i].trigger.gotoAndStop(1);
- _judgeArray[i].trigger.wc2.wc3.gotoAndStop(1);
- _judgeArray[i].motion.gotoAndStop(1);
- _judgeArray[i].motion.wc2.wc3.gotoAndStop(1);
- createPerfume(_judgeArray[i].trigger);
- }
- var t:ITween = BetweenAS3.parallel
- (
- BetweenAS3.tween(_judgeArray[0].trigger, { alpha:0 }, null, 1),
- BetweenAS3.tween(_judgeArray[1].trigger, { alpha:0 }, null, 1)
- );
- t.addEventListener(TweenEvent.COMPLETE, function(event:TweenEvent):void
- {
- _judgeArray[0].trigger.visible = false;
- _judgeArray[1].trigger.visible = false;
- _judgeArray[0].trigger.alpha = 1;
- _judgeArray[1].trigger.alpha = 1;
- _combo++;
- _score += _combo;
- _life++;
- updateScore();
- updateLife();
- addListener();
- _judgeArray = [];
- _restCount -= 2;
- if (_restCount == 0)
- {
- regenerate();
- }
- });
- t.play();
- }
- });
- }
- else
- {
- //trace("はずれ");
- _judgeArray[1].motion.wc2.wc3.addEventListener(Event.ENTER_FRAME, function(event:Event):void
- {
- _judgeArray[1].motion.wc2.wc3.nextFrame;
- if (_judgeArray[1].motion.wc2.wc3.currentFrame == _judgeArray[1].motion.wc2.wc3.totalFrames)
- {
- _judgeArray[1].motion.wc2.wc3.removeEventListener(Event.ENTER_FRAME, arguments.callee);
- for (i = 0; i < 2; i++)
- {
- _judgeArray[i].trigger.visible = true;
- _judgeArray[i].motion.visible = false;
- _judgeArray[i].trigger.gotoAndStop(1);
- _judgeArray[i].trigger.wc2.wc3.gotoAndStop(1);
- _judgeArray[i].motion.gotoAndStop(1);
- _judgeArray[i].motion.wc2.wc3.gotoAndStop(1);
- }
- _combo = 0;
- _life--;
- if (_life == 0)
- {
- gameOver();
- updateLife();
- _judgeArray = [];
- }
- else
- {
- updateLife();
- addListener();
- _judgeArray = [];
- }
- }
- });
- }
- }
- }
- /**
- * rank
- */
- private function rank():String
- {
- var str:String = "";
- if (_score <= 10)
- {
- str = "【 未熟な掃除人 】";
- }
- else if (_score > 10 && _score <= 30)
- {
- str = "【 普通の掃除人 】";
- }
- else if (_score > 30 && _score <= 50)
- {
- str = "【 いけてる掃除人 】";
- }
- else if (_score > 50 && _score <= 80)
- {
- str = "【 最高の掃除人 】";
- }
- else if (_score > 80)
- {
- str = "【 伝説の掃除人 】";
- }
- return str;
- }
- /**
- * createGameOver
- */
- private function createGameOver():Sprite
- {
- var sprite:Sprite = new Sprite();
- sprite.graphics.beginFill(0x000000, 0.8);
- sprite.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
- sprite.graphics.endFill();
- var format:TextFormat = new TextFormat();
- format.color = 0xFFFFFF;
- format.align = "center";
- var field:TextField = createField(format, "GAME OVER\n\nあなたのランクは\n" + rank() + "\n\n\nCLICK TO RETRY");
- field.mouseEnabled = false;
- field.x = (stage.stageWidth - field.width) / 2;
- field.y = (stage.stageHeight - field.height) / 2;
- sprite.addChild(field);
- return sprite;
- }
- /**
- * createField
- * @param format
- * @param str
- * @return textField
- */
- private function createField(format:TextFormat, str:String):TextField
- {
- var field:TextField = new TextField();
- field.defaultTextFormat = format;
- field.autoSize = "left";
- field.selectable = false;
- field.text = str;
- return field;
- }
- /**
- * createFormat
- * @param size
- */
- private function createFormat(size:uint):TextFormat
- {
- var format:TextFormat = new TextFormat();
- format.size = size;
- format.font = "_ゴシック";
- format.bold = true;
- return format;
- }
- /**
- * おいにー
- */
- private function createPerfume(target:MovieClip):void
- {
- var sprite:Sprite = new Sprite();
- sprite.graphics.beginFill(0x996600, 1);
- sprite.graphics.drawCircle(0, 0, 25);
- sprite.graphics.endFill();
- sprite.x = target.x;
- sprite.y = target.y - 30;
- sprite.filters = [_blur];
- addChild(sprite);
- var t:ITween = BetweenAS3.tween(sprite, { y:target.y - 70, alpha:0 }, null, 1 );
- t.addEventListener(TweenEvent.COMPLETE, function():void
- {
- t.removeEventListener(TweenEvent.COMPLETE, arguments.callee);
- removeChild(sprite);
- });
- t.play();
- }
- }
- }
- 出題者からのコメント
- 神経衰弱と聞くとカードを思いつきますが、そういえば動きでもできるんだなと、ハッとしました。
- Comments from King
- "Pelmanism" reminded me playing cards, but I realized we can implement it by motion.








