忍者ブログ
  • 2024.04«
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • » 2024.06
[PR]
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

【2024/05/18 19:22 】 |
[プログラミング][ゲーム][Flash][Flex][AS3]ゲームを作ろうと思った
ゲームを作ろうと思い、その足がかりとして1時間である程度まで作ってみた。
開発は「Adobe Flex Builder 3 Standard」を使いました。

OKを押してから10秒間で何回「赤い円」をクリックできるか。
ただ、それだけ。



最初思いついた時は60秒で考えてたんだけど、さすがにこれだけのものを60秒も遊んでられなかったw
というわけで、10秒に設定しました。

ここからどうするか、一応構想はあるんだけどなぁ。
まぁ、とりあえず今週末にやるだけやってみるか。

つづきにソースコードをのっけておきます。
Shooting.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:action="action.*" layout="absolute"
    width="400" height="420">
    <action:ShootingAction />
    <mx:Label id="scoreLabel" x="280" height="20" fontSize="15" />
    <mx:UIComponent id="field" y="20" width="400" height="400" />
</mx:Application>

action/ShootingAction.as
package action {
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.utils.Timer;
   
    import model.*;
   
    import mx.controls.Alert;
    import mx.core.IMXMLObject;
    import mx.events.CloseEvent;
    import mx.events.FlexEvent;
   
    public class ShootingAction implements IMXMLObject {
       
        private var view:Shooting;
       
        private var score:int = 0;
       
        public function ShootingAction() {
        }
       
        public function initialized(document:Object, id:String):void {
            view = document as Shooting;
            view.addEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler);
        }
       
        private function creationCompleteHandler(event:FlexEvent):void {
            Alert.show("Start", "", 4, null, alertCloseHandler);
        }
       
        private function circleClickHandler(event:MouseEvent):void {
            event.target.removeEventListener(MouseEvent.CLICK, circleClickHandler);
            score += 10;
            view.scoreLabel.text = "Score: " + score;
            view.field.removeChildAt(0);
            var c:Circle = new Circle();
            c.addEventListener(MouseEvent.CLICK, circleClickHandler);
            view.field.addChild(c);
        }
       
        private function alertCloseHandler(event:CloseEvent):void {
            score = 0;
            view.scoreLabel.text = "Score: " + score;
           
            if (view.field.numChildren > 0) {
                view.field.removeChildAt(0);
            }
            var c:Circle = new Circle();
            c.addEventListener(MouseEvent.CLICK, circleClickHandler);
            view.field.addChild(c);
           
            var timer:Timer = new Timer(10000, 1);
            timer.addEventListener(TimerEvent.TIMER, timerCompleteHandler);
            timer.start();
        }

        private function timerCompleteHandler(event:TimerEvent):void {
            Alert.show("得点は" + score + "点です", "", 4, null, alertCloseHandler);
        }
    }
}

model/Circle.as
package model {
    import flash.display.Sprite;
   
    public class Circle extends Sprite {
        public function Circle() {
            this.x = Math.random() * 380 + 10;
            this.y = Math.random() * 380 + 10;
            this.graphics.beginFill(0xFF0000);
            this.graphics.drawCircle(0, 0, 10);
            this.graphics.endFill();
        }
    }
}
PR
【2009/06/26 00:45 】 | プログラミング | 有り難いご意見(0) | トラックバック()
<<[本][森博嗣]封印再度 | ホーム | [本][森博嗣]詩的私的ジャック>>
有り難いご意見
貴重なご意見の投稿















虎カムバック
トラックバックURL

前ページ | ホーム | 次ページ

忍者ブログ [PR]