Ejemplo n.º 1
0
        public VisualCannon(StarlingGameSpriteWithCannonTextures textures, StarlingGameSpriteBase Context)
        {
            mount = new Image(
                textures.tracergun_mount()
                )
            {
            }.AttachTo(
                Context.Content_layer0_tracks
                );

            shadow = new Image(
                textures.tracergun_guntower_shadow()
                )
            {
            }.AttachTo(
                Context.Content_layer2_shadows
                );

            guntower = new Image(
                textures.tracergun_guntower()
                )
            {
            }.AttachTo(
                Context.Content_layer3_buildings
                );
        }
        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();
            }
                );
        }
        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();
            }
                );
        }
        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();
            }
                );
        }
Ejemplo n.º 5
0
        public VisualPed(StarlingGameSpriteWithPedTextures textures, StarlingGameSpriteBase Context, int AnimateSeed = 0)
        {
            this.AnimateSeed = AnimateSeed;
            this.Context     = Context;

            walk_ani = new[] {
                textures.ped_walk.ped_walk3_leftclose(),
                    textures.ped_walk.ped_walk3x_rightclose(),
                    textures.ped_walk.ped_walk1x_rightfar(),
                    textures.ped_walk.ped_walk2x_rightmid(),
                    textures.ped_walk.ped_walk3x_rightclose(),
                    textures.ped_walk.ped_walk3_leftclose(),
                    textures.ped_walk.ped_walk1_leftfar(),
                    textures.ped_walk.ped_walk2_leftmid(),
            };

            walkzombie_ani = new[] {
                textures.ped_walkzombie.ped_walk3_leftclose(),
                    textures.ped_walkzombie.ped_walk3x_rightclose(),
                    textures.ped_walkzombie.ped_walk1x_rightfar(),
                    textures.ped_walkzombie.ped_walk2x_rightmid(),
                    textures.ped_walkzombie.ped_walk3x_rightclose(),
                    textures.ped_walkzombie.ped_walk3_leftclose(),
                    textures.ped_walkzombie.ped_walk1_leftfar(),
                    textures.ped_walkzombie.ped_walk2_leftmid(),
            };

            texframes = new[] {
                textures.ped_walk.ped_stand(),
                    textures.ped_walk.ped_down(),
                    textures.ped_walkzombie.ped_stand(),
                    textures.ped_walkzombie.ped_down(),
                    textures.ped_walk.ped_gunstand_fire(),
                    textures.ped_walk.ped_gunstand(),
            };

            // 781
            // 15 FPS
            // 60 FPS
            // 31  FPS

            // 41
            //var q = new Sprite().AttachTo(Content);

            // Error: Error #3691: Resource limit for this resource type exceeded.
            shadow = new Image(
                textures.ped_shadow()
                )
            {
                // fkn expensive!!
                //alpha = 0.5
            }.AttachTo(Context.Content_layer2_shadows);



            currentvisual = new Image(
                texframes[0])
            {
            }.AttachTo(
                Context.Content_layer3_buildings
                );
        }
        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";
                }
            }
                );
        }
Ejemplo n.º 7
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();
        }
        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
            }
                );
        }
        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());
            }
                );
        }
        // 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();
            }
                );
        }
        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());
            }
                );
        }
        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();
            }
                );
        }
Ejemplo n.º 13
0
        public VisualTank(StarlingGameSpriteWithTankTextures textures, StarlingGameSpriteBase Context)
        {
            this.Context = Context;



            #region visual
            currentshadow = new Image(
                textures.greentank_shadow()
                )
            {
            }.AttachTo(
                Context.Content_layer2_shadows
                );

            currentvisual = new Sprite().AttachTo(Context.Content);



            tanktrackpattern1 = new Image(
                textures.tanktrackpattern()
                )
            {
            }.AttachTo(
                currentvisual
                );


            tanktrackpattern0 = new Image(
                textures.tanktrackpattern()
                )
            {
            }.AttachTo(
                currentvisual
                );


            var imgstand = new Image(
                textures.greentank()
                )
            {
            }.AttachTo(
                currentvisual
                );

            var guntower = new Image(
                textures.greentank_guntower()
                )
            {
            }.AttachTo(
                currentvisual
                );



            {
                var cm = new Matrix();

                cm.translate(-64, -64);
                cm.scale(0.55, 0.75);

                tanktrackpattern0.transformationMatrix = cm;
                tanktrackpattern1.transformationMatrix = cm;
            }

            // rpeate not suppported!
            // http://forum.starling-framework.org/topic/problem-with-repeat-and-textureatlas



            {
                var cm = new Matrix();

                cm.translate(-64, -64);

                imgstand.transformationMatrix = cm;
            }

            {
                var cm = new Matrix();

                cm.translate(-64, -64);

                guntower.transformationMatrix = cm;
            }

            //{
            //    var cm = new Matrix();

            //    cm.translate(-64, -64);

            //    // shadow with tracks!
            //    cm.scale(1.2, 1.0);
            //    //cm.rotate(rot);
            //    //cm.translate(i * 128, yi * 128);

            //    cm.translate(8, 8);

            //    currentshadow.transformationMatrix = cm;
            //}

            //{
            //    var cm = new Matrix();

            //    //cm.rotate(rot);
            //    //cm.translate(i * 128, yi * 128);


            //    currentvisual.transformationMatrix = cm;
            //}

            #endregion
        }
Ejemplo n.º 14
0
        public VisualJeep(StarlingGameSpriteWithJeepTextures textures, StarlingGameSpriteBase Context)
        {
            shadow = new Image(
                textures.jeep_shadow()
                )
            {
            }.AttachTo(
                Context.Content_layer2_shadows
                //q
                );

            currentvisual = new Sprite().AttachTo(Context.Content);



            tire0 = new Image(
                textures.black4()
                )
            {
            }.AttachTo(
                //Content
                currentvisual
                );

            tire1 = new Image(textures.black4()).AttachTo(currentvisual);
            tire2 = new Image(textures.black4()).AttachTo(currentvisual);
            tire3 = new Image(textures.black4()).AttachTo(currentvisual);

            var imgstand = new Image(
                textures.jeep()
                )
            {
            }.AttachTo(
                //Content
                currentvisual
                );



            {
                var cm = new Matrix();
                cm.translate(-2, -2);
                cm.scale(2, 4);
                cm.rotate(Math.PI * 0.1);

                cm.translate(-18, -20);

                tire0.transformationMatrix = cm;
            }

            {
                var cm = new Matrix();
                cm.translate(-2, -2);
                cm.scale(2, 4);
                cm.rotate(Math.PI * 0.1);

                cm.translate(18, -20);

                tire1.transformationMatrix = cm;
            }

            {
                var cm = new Matrix();
                cm.translate(-2, -2);
                cm.scale(2, 4);

                cm.translate(-18, 20);

                tire2.transformationMatrix = cm;
            }


            {
                var cm = new Matrix();
                cm.translate(-2, -2);
                cm.scale(2, 4);

                cm.translate(18, 20);

                tire3.transformationMatrix = cm;
            }


            {
                var cm = new Matrix();
                cm.translate(-32, -32);
                imgstand.transformationMatrix = cm;
            }
        }
        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
            }
                );
        }