コード例 #1
0
        public ApplicationSprite()
        {
            this.InvokeWhenStageIsReady(
                delegate
            {
                this.stage.color     = 0x006D00;
                this.stage.frameRate = 30;
                this.stage.frameRate = 60;

                // http://gamua.com/starling/first-steps/
                // http://forum.starling-framework.org/topic/starling-air-desktop-extendeddesktop-fullscreen-issue
                Starling.handleLostContext = true;

                var s = new Starling(
                    typeof(StarlingGameSpriteWithPedControl).ToClassToken(),
                    this.stage,

                    // http://forum.starling-framework.org/topic/air-34
                    profile: "baseline"
                    );


                //Starling.current.showStats

                s.showStats = true;

                #region atresize
                Action atresize = delegate
                {
                    // http://forum.starling-framework.org/topic/starling-stage-resizing

                    s.viewPort = new ScriptCoreLib.ActionScript.flash.geom.Rectangle(
                        0, 0, this.stage.stageWidth, this.stage.stageHeight
                        );

                    s.stage.stageWidth  = this.stage.stageWidth;
                    s.stage.stageHeight = this.stage.stageHeight;


                    //b2stage_centerize();
                };

                atresize();
                #endregion

                StarlingGameSpriteBase.onresize =
                    yield =>
                {
                    this.stage.resize += delegate
                    {
                        atresize();

                        yield(this.stage.stageWidth, this.stage.stageHeight);
                    };

                    yield(this.stage.stageWidth, this.stage.stageHeight);
                };



                this.stage.enterFrame +=
                    delegate
                {
                    StarlingGameSpriteBase.onframe(this.stage, s);
                };

                s.start();
            }
                );
        }
コード例 #2
0
        public ApplicationSprite()
        {
            #region __transport
            for (int i = 0; i < 7; i++)
            {
                lag.Enqueue(new List <string>());
            }

            var lagtimer = new ScriptCoreLib.ActionScript.flash.utils.Timer(1000 / 15);

            lagtimer.timer +=
                delegate
            {
                lag.Enqueue(PendingInput);

                PendingInput = lag.Dequeue();

                foreach (var xml in PendingInput)
                {
                    this.__transport_in(xml);
                }

                PendingInput.Clear();
            };

            lagtimer.start();

            StarlingGameSpriteWithTankSync.__raise_sync +=
                egoid =>
            {
                // Error	8	Argument 1: cannot convert from 'System.Xml.Linq.XAttribute' to 'System.Xml.Linq.XStreamingElement'	X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.UnitPedSync\ApplicationSprite.cs	40	33	FlashHeatZeeker.UnitPedSync

                var xml = new XElement("sync", new XAttribute("egoid", egoid));

                if (__transport_out != null)
                {
                    __transport_out(xml.ToString());
                }
            };

            StarlingGameSpriteWithTankSync.__raise_SetVelocityFromInput +=
                (
                    string __egoid,
                    string __identity,
                    string __KeySample,
                    string __fixup_x,
                    string __fixup_y,
                    string __fixup_angle

                ) =>
            {
                var xml = new XElement("SetVelocityFromInput",

                                       new XAttribute("egoid", __egoid),


                                       new XAttribute("i", __identity),
                                       new XAttribute("k", __KeySample),
                                       new XAttribute("x", __fixup_x),
                                       new XAttribute("y", __fixup_y),
                                       new XAttribute("angle", __fixup_angle)

                                       );

                if (__transport_out != null)
                {
                    __transport_out(xml.ToString());
                }
            };
            #endregion

            this.InvokeWhenStageIsReady(
                delegate
            {
                // http://gamua.com/starling/first-steps/
                // http://forum.starling-framework.org/topic/starling-air-desktop-extendeddesktop-fullscreen-issue
                Starling.handleLostContext = true;

                var s = new Starling(
                    typeof(StarlingGameSpriteWithTankSync).ToClassToken(),
                    this.stage
                    );


                //Starling.current.showStats

                s.showStats = true;

                // when can we have live constant updates?
                new net.hires.debug.Stats().AttachToSprite().MoveTo(0, 48);

                #region atresize
                Action atresize = delegate
                {
                    // http://forum.starling-framework.org/topic/starling-stage-resizing

                    s.viewPort = new ScriptCoreLib.ActionScript.flash.geom.Rectangle(
                        0, 0, this.stage.stageWidth, this.stage.stageHeight
                        );

                    s.stage.stageWidth  = this.stage.stageWidth;
                    s.stage.stageHeight = this.stage.stageHeight;


                    //b2stage_centerize();
                };

                atresize();
                #endregion

                StarlingGameSpriteBase.onresize =
                    yield =>
                {
                    this.stage.resize += delegate
                    {
                        atresize();

                        yield(this.stage.stageWidth, this.stage.stageHeight);
                    };

                    yield(this.stage.stageWidth, this.stage.stageHeight);
                };



                this.stage.enterFrame +=
                    delegate
                {
                    StarlingGameSpriteBase.onframe(this.stage, s);
                };

                s.start();
            }
                );
        }
コード例 #3
0
        public ApplicationSprite()
        {
            this.InvokeWhenPromotionIsReady(
                () =>
            {
                this.stage.color     = 0;
                this.stage.frameRate = 30;
                this.stage.frameRate = 60;

                // http://gamua.com/starling/first-steps/
                // http://forum.starling-framework.org/topic/starling-air-desktop-extendeddesktop-fullscreen-issue
                Starling.handleLostContext = true;

                var s = new Starling(
                    typeof(StarlingGameSpriteWithTestGamePad).ToClassToken(),
                    this.stage,

                    // http://forum.starling-framework.org/topic/air-34
                    profile: "baseline"
                    );


                //Starling.current.showStats

                s.showStats = true;

                #region atresize
                Action atresize = delegate
                {
                    // http://forum.starling-framework.org/topic/starling-stage-resizing

                    s.viewPort = new ScriptCoreLib.ActionScript.flash.geom.Rectangle(
                        0, 0, this.stage.stageWidth, this.stage.stageHeight
                        );

                    s.stage.stageWidth  = this.stage.stageWidth;
                    s.stage.stageHeight = this.stage.stageHeight;


                    //b2stage_centerize();
                };

                atresize();
                #endregion

                StarlingGameSpriteBase.onresize =
                    yield =>
                {
                    this.stage.resize += delegate
                    {
                        atresize();

                        yield(this.stage.stageWidth, this.stage.stageHeight);
                    };

                    yield(this.stage.stageWidth, this.stage.stageHeight);
                };



                this.stage.enterFrame +=
                    delegate
                {
                    StarlingGameSpriteBase.onframe(this.stage, s);
                };

                s.start();

                #region FULL_SCREEN_INTERACTIVE
                this.stage.keyUp +=
                    e =>
                {
                    if (e.keyCode == (uint)System.Windows.Forms.Keys.F11)
                    {
                        this.stage.displayState = ScriptCoreLib.ActionScript.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
                    }

                    if (e.keyCode == (uint)System.Windows.Forms.Keys.F)
                    {
                        this.stage.displayState = ScriptCoreLib.ActionScript.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
                    }
                };
                #endregion

                content.r.Opacity = 0;
                content.AttachToContainer(this);
                content.AutoSizeTo(this.stage);



                var InactiveOpaciy = 0.07;
                var ActiveOpaciy   = 0.5;


                #region bind
                Action <UIElement, Keys> bind =
                    (ui, key) =>
                {
                    //                    Implementation not found for type import :
                    //type: System.Windows.UIElement
                    //method: Void add_MouseDown(System.Windows.Input.MouseButtonEventHandler)

                    //ui.MouseDown +=
                    ui.Opacity = InactiveOpaciy;

                    ui.MouseLeftButtonDown +=
                        (sender, e) =>
                    {
                        ui.Opacity = ActiveOpaciy;
                        e.Handled  = true;
                        StarlingGameSpriteWithTestGamePad.__keyDown[key] = true;
                    };

                    //ui.MouseUp +=
                    ui.MouseLeftButtonUp +=
                        (sender, e) =>
                    {
                        ui.Opacity = InactiveOpaciy;
                        e.Handled  = true;
                        StarlingGameSpriteWithTestGamePad.__keyDown[key] = false;
                    };

                    ui.TouchDown +=
                        (sender, e) =>
                    {
                        ui.Opacity = ActiveOpaciy;
                        e.Handled  = true;
                        StarlingGameSpriteWithTestGamePad.__keyDown[key] = true;
                    };

                    ui.TouchUp +=
                        (sender, e) =>
                    {
                        ui.Opacity = InactiveOpaciy;
                        e.Handled  = true;
                        StarlingGameSpriteWithTestGamePad.__keyDown[key] = false;
                    };
                };
                #endregion
                //bind(content.up, Keys.Up);
                //bind(content.down, Keys.Down);
                //bind(content.left, Keys.Left);
                //bind(content.right, Keys.Right);
                bind(content.enter, Keys.Enter);
                bind(content.space, Keys.Space);
                bind(content.control, Keys.ControlKey);
                bind(content.alt, Keys.Alt);


                var text       = new TextField().AttachTo(this);
                text.width     = 800;
                text.y         = 72;
                text.textColor = 0xffffff;
                text.multiline = true;

                if (Accelerometer.isSupported)
                {
                    StarlingGameSpriteWithTestGamePad.__keyDown.InitializeConnection(
                        text: text,


                        yield_Notify:
                        xml =>
                    {
                        if (xml.Name.LocalName == "switchto")
                        {
                            var type = xml.Attribute("type").Value;

                            StarlingGameSpriteWithTestGamePad.__switchto(type);
                        }
                    }
                        );

                    //var a = new Accelerometer();
                    a = new Accelerometer();

                    a.update +=
                        e =>
                    {
                        //text.text = new
                        //{
                        //    x = e.accelerationX,
                        //    y = e.accelerationY,
                        //    z = e.accelerationZ
                        //}.ToString();

                        content.tiltx = 1 - (e.accelerationX + 0.5);
                        content.tilty = e.accelerationY;
                        content.tilt_update();

                        StarlingGameSpriteWithTestGamePad.__keyDown.forcex = ((Math.Abs(content.tiltx - 0.5) / 0.5) - 0.05) * 0.3;
                        StarlingGameSpriteWithTestGamePad.__keyDown.forcey = Math.Abs(content.tilty - 0.5) / 0.5;

                        content.rtiltx.Opacity = StarlingGameSpriteWithTestGamePad.__keyDown.forcex;
                        content.rtilty.Opacity = StarlingGameSpriteWithTestGamePad.__keyDown.forcey;

                        // we did do this for TestDrive example!
                        #region StarlingGameSpriteWithTestGamePad
                        if (e.accelerationX > 0.05)
                        {
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Left]  = true;
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Right] = false;
                        }
                        else if (e.accelerationX < -0.05)
                        {
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Left]  = false;
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Right] = true;
                        }
                        else
                        {
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Left]  = false;
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Right] = false;
                        }
                        #endregion

                        #region accelerationY
                        if (e.accelerationY < 0.1)
                        {
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Up]   = false;
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Down] = false;
                        }
                        else if (e.accelerationY < 0.4)
                        {
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Up]   = true;
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Down] = false;
                        }
                        else if (e.accelerationY > 0.6)
                        {
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Up]   = false;
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Down] = true;
                        }
                        else
                        {
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Up]   = false;
                            StarlingGameSpriteWithTestGamePad.__keyDown[Keys.Down] = false;
                        }
                        #endregion
                    };

                    a.setRequestedUpdateInterval(1000 / 60);
                }
                else
                {
                    StarlingGameSpriteWithTestGamePad.__keyDown.InitializeConnection(WriteMode: false, ReadMode: true, text: text);

                    //text.text = "no Accelerometer";
                }
            }
                );
        }
コード例 #4
0
        public ApplicationSprite()
        {
            this.InvokeWhenStageIsReady(
                delegate
            {
                // http://gamua.com/starling/first-steps/
                // http://forum.starling-framework.org/topic/starling-air-desktop-extendeddesktop-fullscreen-issue
                Starling.handleLostContext = true;

                var s = new Starling(
                    typeof(StarlingGameSpriteWithJeep).ToClassToken(),
                    this.stage
                    //,
                    //  Use this parameter to force "software" rendering.
                    // The Context3DProfile that should be requested.
                    // http://forum.starling-framework.org/topic/air-34

                    // Chrome OpenGL 60 FPS
                    // Nexus 7 Tab OpenGL 27 FPS
                    // Galaxy S OpenGL 16 FPS
                    //profile: "baseline"
                    // constrained mode gives same perfrmance!
                    );


                //Starling.current.showStats

                s.showStats = true;

                #region atresize
                Action atresize = delegate
                {
                    // http://forum.starling-framework.org/topic/starling-stage-resizing

                    s.viewPort = new ScriptCoreLib.ActionScript.flash.geom.Rectangle(
                        0, 0, this.stage.stageWidth, this.stage.stageHeight
                        );

                    s.stage.stageWidth  = this.stage.stageWidth;
                    s.stage.stageHeight = this.stage.stageHeight;


                    //b2stage_centerize();
                };

                atresize();
                #endregion

                StarlingGameSpriteBase.onresize =
                    yield =>
                {
                    this.stage.resize += delegate
                    {
                        atresize();

                        yield(this.stage.stageWidth, this.stage.stageHeight);
                    };

                    yield(this.stage.stageWidth, this.stage.stageHeight);
                };



                this.stage.enterFrame +=
                    delegate
                {
                    StarlingGameSpriteBase.onframe(this.stage, s);
                };

                s.start();
            }
                );
        }
コード例 #5
0
        public void Initialize()
        {
            this.InvokeWhenStageIsReady(
                delegate
            {
                // http://gamua.com/starling/first-steps/
                // http://forum.starling-framework.org/topic/starling-air-desktop-extendeddesktop-fullscreen-issue
                Starling.handleLostContext = true;

                var s = new Starling(
                    typeof(StarlingGameSpriteWithShop).ToClassToken(),
                    this.stage
                    );

                //[SWF(backgroundColor = 0xB27D51)]

                //Starling.current.showStats

                s.showStats = true;

                #region atresize
                Action atresize = delegate
                {
                    // http://forum.starling-framework.org/topic/starling-stage-resizing

                    s.viewPort = new ScriptCoreLib.ActionScript.flash.geom.Rectangle(
                        0, 0, this.stage.stageWidth, this.stage.stageHeight
                        );

                    s.stage.stageWidth  = this.stage.stageWidth;
                    s.stage.stageHeight = this.stage.stageHeight;


                    //b2stage_centerize();
                };

                atresize();
                #endregion

                StarlingGameSpriteBase.onresize =
                    yield =>
                {
                    this.stage.resize += delegate
                    {
                        atresize();

                        yield(this.stage.stageWidth, this.stage.stageHeight);
                    };

                    yield(this.stage.stageWidth, this.stage.stageHeight);
                };



                this.stage.enterFrame +=
                    delegate
                {
                    StarlingGameSpriteBase.onframe(this.stage, s);
                };

                s.start();
            }
                );

            WhenReady();
        }
コード例 #6
0
        public ApplicationSpriteContent()
        {
            this.InvokeWhenStageIsReady(
                delegate
            {
                this.stage.frameRate = 30;
                this.stage.frameRate = 60;

                // http://gamua.com/starling/first-steps/
                // http://forum.starling-framework.org/topic/starling-air-desktop-extendeddesktop-fullscreen-issue
                Starling.handleLostContext = true;

                var s = new Starling(
                    typeof(StarlingGameSpriteWithTestDriversWithAudio).ToClassToken(),
                    this.stage,

                    // http://forum.starling-framework.org/topic/air-34
                    profile: "baseline"
                    );


                //Starling.current.showStats

                s.showStats = true;

                #region atresize
                Action atresize = delegate
                {
                    // http://forum.starling-framework.org/topic/starling-stage-resizing

                    s.viewPort = new ScriptCoreLib.ActionScript.flash.geom.Rectangle(
                        0, 0, this.stage.stageWidth, this.stage.stageHeight
                        );

                    s.stage.stageWidth  = this.stage.stageWidth;
                    s.stage.stageHeight = this.stage.stageHeight;


                    //b2stage_centerize();
                };

                atresize();
                #endregion

                StarlingGameSpriteBase.onresize =
                    yield =>
                {
                    this.stage.resize += delegate
                    {
                        atresize();

                        yield(this.stage.stageWidth, this.stage.stageHeight);
                    };

                    yield(this.stage.stageWidth, this.stage.stageHeight);
                };



                this.stage.enterFrame +=
                    delegate
                {
                    StarlingGameSpriteBase.onframe(this.stage, s);
                };

                s.start();

                #region FULL_SCREEN_INTERACTIVE
                this.stage.keyUp +=
                    e =>
                {
                    if (e.keyCode == (uint)System.Windows.Forms.Keys.F11)
                    {
                        this.stage.displayState = ScriptCoreLib.ActionScript.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
                    }

                    if (e.keyCode == (uint)System.Windows.Forms.Keys.F)
                    {
                        this.stage.displayState = ScriptCoreLib.ActionScript.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
                    }
                };
                #endregion


                #region F8
                var CanConnectAndroid = true;
                this.stage.keyUp     +=
                    e =>
                {
                    if (e.keyCode == (uint)System.Windows.Forms.Keys.F8)
                    {
                        if (!CanConnectAndroid)
                        {
                            return;
                        }

                        CanConnectAndroid = false;

                        var sb = new Soundboard();
                        sb.snd_lookingforlongrangecomms.play(
                            loops: 2,
                            sndTransform: new ScriptCoreLib.ActionScript.flash.media.SoundTransform(0.4)
                            );


                        var text       = new ScriptCoreLib.ActionScript.flash.text.TextField().AttachTo(this);
                        text.width     = 800;
                        text.y         = 72;
                        text.textColor = 0xffffff;
                        text.multiline = true;

                        FlashHeatZeeker.TestGamePad.Library.MulticastService.InitializeConnection(
                            StarlingGameSpriteWithTestDriversWithAudio.__keyDown,
                            WriteMode: false,
                            ReadMode: true,
                            text: text,

                            yield_PostMessage:
                            PostMessage =>
                        {
                            StarlingGameSpriteWithTestDriversWithAudio.current_changed +=
                                g =>
                            {
                                Action <string> __switchto =
                                    type =>
                                {
                                    PostMessage(
                                        new XElement(
                                            "switchto",
                                            new XAttribute("type", type),
                                            new XAttribute("syncframeid", "" + g.syncframeid)

                                            ).ToString());
                                };
                                if (g.current is PhysicalPed)
                                {
                                    __switchto("ped");
                                }
                                if (g.current is PhysicalTank)
                                {
                                    __switchto("tank");
                                }
                                if (g.current is PhysicalJeep)
                                {
                                    __switchto("jeep");
                                }
                                if (g.current is PhysicalHind)
                                {
                                    __switchto("hind");
                                }
                                if (g.current is PhysicalBunker)
                                {
                                    __switchto("bunker");
                                }
                                if (g.current is PhysicalCannon)
                                {
                                    __switchto("cannon");
                                }
                                if (g.current is PhysicalSilo)
                                {
                                    __switchto("silo");
                                }
                                if (g.current is PhysicalWatertower)
                                {
                                    __switchto("watertower");
                                }
                            };
                        }
                            );
                    }
                };
                #endregion
            }
                );
        }
コード例 #7
0
        // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201501/20150110/hz


        //Error: Error #3709: The depthAndStencil flag in the application descriptor must match the enableDepthAndStencil Boolean passed to configureBackBuffer on the Context3D object.
        //    at flash.display3D::Context3D/configureBackBuffer()
        //    at Function/http://adobe.com/AS3/2006/builtin::apply()
        //    at starling.core::Starling/configureBackBuffer()
        //    at starling.core::Starling/updateViewPort()
        //    at starling.core::Starling/initializeGraphicsAPI()
        //    at starling.core::Starling/initialize()
        //    at starling.core::Starling/onContextCreated()


        public ApplicationSprite()
        {
            this.InvokeWhenStageIsReady(
                delegate
            {
                // http://gamua.com/starling/first-steps/
                // http://forum.starling-framework.org/topic/starling-air-desktop-extendeddesktop-fullscreen-issue
                Starling.handleLostContext = true;



                // Error	1	'.ctor' is not supported by the language	X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.UnitTank\ApplicationSprite.cs	24	27	FlashHeatZeeker.UnitTank
                // partial build?
                var s = new Starling(
                    typeof(StarlingGameSpriteWithTank).ToClassToken(),
                    this.stage
                    );


                //Starling.current.showStats

                s.showStats = true;

                #region atresize
                Action atresize = delegate
                {
                    // http://forum.starling-framework.org/topic/starling-stage-resizing

                    s.viewPort = new ScriptCoreLib.ActionScript.flash.geom.Rectangle(
                        0, 0, this.stage.stageWidth, this.stage.stageHeight
                        );

                    s.stage.stageWidth  = this.stage.stageWidth;
                    s.stage.stageHeight = this.stage.stageHeight;


                    //b2stage_centerize();
                };

                atresize();
                #endregion

                StarlingGameSpriteBase.onresize =
                    yield =>
                {
                    this.stage.resize += delegate
                    {
                        atresize();

                        yield(this.stage.stageWidth, this.stage.stageHeight);
                    };

                    yield(this.stage.stageWidth, this.stage.stageHeight);
                };



                this.stage.enterFrame +=
                    delegate
                {
                    StarlingGameSpriteBase.onframe(this.stage, s);
                };

                s.start();
            }
                );
        }
コード例 #8
0
        public ApplicationSprite()
        {
            this.InvokeWhenStageIsReady(
                delegate
            {
                // http://gamua.com/starling/first-steps/
                // http://forum.starling-framework.org/topic/starling-air-desktop-extendeddesktop-fullscreen-issue
                Starling.handleLostContext = true;

                var s = new Starling(
                    typeof(StarlingGameSpriteWithTankControl).ToClassToken(),
                    this.stage
                    );


                //Starling.current.showStats

                //s.showStats = true;

                #region atresize
                Action atresize = delegate
                {
                    // http://forum.starling-framework.org/topic/starling-stage-resizing

                    s.viewPort = new ScriptCoreLib.ActionScript.flash.geom.Rectangle(
                        0, 0, this.stage.stageWidth, this.stage.stageHeight
                        );

                    s.stage.stageWidth  = this.stage.stageWidth;
                    s.stage.stageHeight = this.stage.stageHeight;


                    //b2stage_centerize();
                };

                atresize();
                #endregion

                StarlingGameSpriteBase.onresize =
                    yield =>
                {
                    this.stage.resize += delegate
                    {
                        atresize();

                        yield(this.stage.stageWidth, this.stage.stageHeight);
                    };

                    yield(this.stage.stageWidth, this.stage.stageHeight);
                };



                this.stage.enterFrame +=
                    delegate
                {
                    StarlingGameSpriteBase.onframe(this.stage, s);
                };

                s.start();

                // http://www.flare3d.com/support/index.php?topic=1101.0
                this.addChild(new net.hires.debug.Stats());
            }
                );
        }
コード例 #9
0
        public ApplicationSprite()
        {
            this.InvokeWhenStageIsReady(
                delegate
            {
                // ??
                // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#color
                //this.stage.color = 0xA26D41;

                this.stage.frameRate = 30;
                this.stage.frameRate = 60;

                // http://gamua.com/starling/first-steps/
                // http://forum.starling-framework.org/topic/starling-air-desktop-extendeddesktop-fullscreen-issue
                Starling.handleLostContext = true;

                // 30 FPS
                //StarlingGameSpriteDemo.DefaultLogoCount = 64;

                // 60 FPS
                StarlingGameSpriteDemo.DefaultLogoCount = 32;


                var s = new Starling(
                    typeof(StarlingGameSpriteDemo).ToClassToken(),
                    this.stage,

                    // http://forum.starling-framework.org/topic/air-34
                    profile: "baseline"
                    );


                //Starling.current.showStats

                s.showStats = true;

                #region atresize
                Action atresize = delegate
                {
                    // http://forum.starling-framework.org/topic/starling-stage-resizing

                    s.viewPort = new ScriptCoreLib.ActionScript.flash.geom.Rectangle(
                        0, 0, this.stage.stageWidth, this.stage.stageHeight
                        );

                    s.stage.stageWidth  = this.stage.stageWidth;
                    s.stage.stageHeight = this.stage.stageHeight;


                    //b2stage_centerize();
                };

                atresize();
                #endregion


                StarlingGameSpriteBase.onresize =
                    yield =>
                {
                    this.stage.resize += delegate
                    {
                        atresize();

                        yield(this.stage.stageWidth, this.stage.stageHeight);
                    };
                };


                var c = 0;

                this.stage.enterFrame +=
                    delegate
                {
                    StarlingGameSpriteBase.onframe(this.stage, s);

                    c++;
                };

                s.start();

                // http://www.flare3d.com/support/index.php?topic=1101.0
                this.addChild(new Stats());
            }
                );
        }
コード例 #10
0
        public ApplicationSprite()
        {
            #region __transport
            for (int i = 0; i < 7; i++)
            {
                lag.Enqueue(new List <string>());
            }

            var lagtimer = new ScriptCoreLib.ActionScript.flash.utils.Timer(1000 / 15);

            lagtimer.timer +=
                delegate
            {
                lag.Enqueue(PendingInput);

                PendingInput = lag.Dequeue();

                foreach (var xml in PendingInput)
                {
                    this.__transport_in(xml);
                }

                PendingInput.Clear();
            };

            lagtimer.start();


            StarlingGameSpriteWithPedSync.__raise_sync +=
                egoid =>
            {
                // Error	8	Argument 1: cannot convert from 'System.Xml.Linq.XAttribute' to 'System.Xml.Linq.XStreamingElement'	X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.UnitPedSync\ApplicationSprite.cs	40	33	FlashHeatZeeker.UnitPedSync

                var xml = new XElement("sync", new XAttribute("egoid", egoid));

                if (__transport_out != null)
                {
                    __transport_out(xml.ToString());
                }
            };

            StarlingGameSpriteWithPedSync.__raise_SetVelocityFromInput +=
                (
                    string __egoid,
                    string __identity,
                    string __KeySample,
                    string __fixup_x,
                    string __fixup_y,
                    string __fixup_angle

                ) =>
            {
                var xml = new XElement("SetVelocityFromInput",

                                       new XAttribute("egoid", __egoid),


                                       new XAttribute("i", __identity),
                                       new XAttribute("k", __KeySample),
                                       new XAttribute("x", __fixup_x),
                                       new XAttribute("y", __fixup_y),
                                       new XAttribute("angle", __fixup_angle)

                                       );

                if (__transport_out != null)
                {
                    __transport_out(xml.ToString());
                }
            };
            #endregion

            #region AtInitializeConsoleFormWriter

            var w         = new __OutWriter();
            var o         = Console.Out;
            var __reentry = false;

            var __buffer = new StringBuilder();

            w.AtWrite =
                x =>
            {
                __buffer.Append(x);
            };

            w.AtWriteLine =
                x =>
            {
                __buffer.AppendLine(x);
            };

            Console.SetOut(w);

            this.AtInitializeConsoleFormWriter = (
                Action <string> Console_Write,
                Action <string> Console_WriteLine
                ) =>
            {
                try
                {
                    w.AtWrite =
                        x =>
                    {
                        o.Write(x);

                        if (!__reentry)
                        {
                            __reentry = true;
                            Console_Write(x);
                            __reentry = false;
                        }
                    };

                    w.AtWriteLine =
                        x =>
                    {
                        o.WriteLine(x);

                        if (!__reentry)
                        {
                            __reentry = true;
                            Console_WriteLine(x);
                            __reentry = false;
                        }
                    };

                    Console.WriteLine("flash Console.WriteLine should now appear in JavaScript form!");
                    Console.WriteLine(__buffer.ToString());
                }
                catch
                {
                }
            };
            #endregion



            this.InvokeWhenStageIsReady(
                delegate
            {
                // http://gamua.com/starling/first-steps/
                // http://forum.starling-framework.org/topic/starling-air-desktop-extendeddesktop-fullscreen-issue
                Starling.handleLostContext = true;

                var s = new Starling(
                    typeof(StarlingGameSpriteWithPedSync).ToClassToken(),
                    this.stage
                    );


                //Starling.current.showStats

                s.showStats = true;

                #region atresize
                Action atresize = delegate
                {
                    // http://forum.starling-framework.org/topic/starling-stage-resizing

                    s.viewPort = new ScriptCoreLib.ActionScript.flash.geom.Rectangle(
                        0, 0, this.stage.stageWidth, this.stage.stageHeight
                        );

                    s.stage.stageWidth  = this.stage.stageWidth;
                    s.stage.stageHeight = this.stage.stageHeight;


                    //b2stage_centerize();
                };

                atresize();
                #endregion

                StarlingGameSpriteBase.onresize =
                    yield =>
                {
                    this.stage.resize += delegate
                    {
                        atresize();

                        yield(this.stage.stageWidth, this.stage.stageHeight);
                    };

                    yield(this.stage.stageWidth, this.stage.stageHeight);
                };



                this.stage.enterFrame +=
                    delegate
                {
                    StarlingGameSpriteBase.onframe(this.stage, s);
                };

                s.start();
            }
                );
        }
コード例 #11
0
        public ApplicationSprite()
        {
            this.InvokeWhenStageIsReady(
                delegate
            {
                this.stage.color     = 0xA26D41;
                this.stage.frameRate = 30;
                this.stage.frameRate = 60;

                // http://gamua.com/starling/first-steps/
                // http://forum.starling-framework.org/topic/starling-air-desktop-extendeddesktop-fullscreen-issue
                Starling.handleLostContext = true;

                var s = new Starling(
                    typeof(StarlingGameSpriteWithHindWeaponized).ToClassToken(),
                    this.stage,

                    // http://forum.starling-framework.org/topic/air-34
                    profile: "baseline"
                    );


                //Starling.current.showStats

                s.showStats = true;

                #region atresize
                Action atresize = delegate
                {
                    // http://forum.starling-framework.org/topic/starling-stage-resizing

                    s.viewPort = new ScriptCoreLib.ActionScript.flash.geom.Rectangle(
                        0, 0, this.stage.stageWidth, this.stage.stageHeight
                        );

                    s.stage.stageWidth  = this.stage.stageWidth;
                    s.stage.stageHeight = this.stage.stageHeight;


                    //b2stage_centerize();
                };

                atresize();
                #endregion

                StarlingGameSpriteBase.onresize =
                    yield =>
                {
                    this.stage.resize += delegate
                    {
                        atresize();

                        yield(this.stage.stageWidth, this.stage.stageHeight);
                    };

                    yield(this.stage.stageWidth, this.stage.stageHeight);
                };



                this.stage.enterFrame +=
                    delegate
                {
                    StarlingGameSpriteBase.onframe(this.stage, s);
                };

                s.start();


                #region FULL_SCREEN_INTERACTIVE
                this.stage.keyUp +=
                    e =>
                {
                    //dynamic dstage = this.stage;

                    if (e.keyCode == (uint)System.Windows.Forms.Keys.F11)
                    {
                        this.stage.displayState = ScriptCoreLib.ActionScript.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;

                        // ReferenceError: Error #1056: Cannot create property mouseLock on flash.display.Stage.
                        //dstage.mouseLock = true;
                    }

                    if (e.keyCode == (uint)System.Windows.Forms.Keys.F)
                    {
                        this.stage.displayState = ScriptCoreLib.ActionScript.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
                        //dstage.mouseLock = true;

                        // http://www.levelxgames.com/2012/11/how-to-overlay-abode-air-sdk-over-flex-sdk/
                    }
                };
                #endregion
            }
                );
        }