Ejemplo n.º 1
0
        public double redOffset; // { get; set; }

        #endregion

        #region Methods
        /// <summary>
        /// Concatenates the ColorTranform object specified by the second parameter with the current ColorTransform object and sets the current object as the result, which is an additive combination of the two color transformations.
        /// </summary>
        public void concat(ColorTransform second)
        {
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adjusts the color values in a specified area of a bitmap image by using a ColorTransform object.
 /// </summary>
 public void colorTransform(Rectangle rect, ColorTransform colorTransform)
 {
 }
Ejemplo n.º 3
0
        public double redOffset; // { get; set; }

        #endregion

        #region Methods
        /// <summary>
        /// Concatenates the ColorTranform object specified by the second parameter with the current ColorTransform object and sets the current object as the result, which is an additive combination of the two color transformations.
        /// </summary>
        public void concat(ColorTransform second)
        {
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Draws the source display object onto the bitmap image, using the Flash Player or AIR vector renderer.
 /// </summary>
 public void draw(IBitmapDrawable source, Matrix matrix, ColorTransform colorTransform)
 {
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Draws the source display object onto the bitmap image, using the Flash Player or AIR vector renderer.
 /// </summary>
 public void draw(IBitmapDrawable source, Matrix matrix, ColorTransform colorTransform, string blendMode)
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Draws the source display object onto the bitmap image, using the Flash Player or AIR vector renderer.
 /// </summary>
 public void draw(IBitmapDrawable source, Matrix matrix, ColorTransform colorTransform, string blendMode, Rectangle clipRect)
 {
 }
        public static void ToMouseCursor(this Sprite c)
        {
            // http://www.kirupa.com/forum/showthread.php?274754-bitmapData-transparency

            var u = new BitmapData(32, 32, transparent: true, fillColor: 0x00FFFFFFu);

            var adjustAlpha = new ColorTransform();

            //adjustAlpha.alphaMultiplier = 0.5;

            var m = new Matrix();

            u.draw(c, m, adjustAlpha, BlendMode.NORMAL);


            var data = new BitmapData[] {
                    u
                };

            // X:\jsc.svn\examples\actionscript\FlashMouseCursorDataExperiment\FlashMouseCursorDataExperiment\ApplicationSprite.cs
            var cursor = new MouseCursorData
            {
                data = data
            };

            // http://stackoverflow.com/questions/16004940/error-2136-swf-contains-invalid-data
            //Error: Error #2136: The SWF file file:///X|/jsc.svn/examples/actionscript/svg/FlashSVGCursorExperiment/FlashSVGCursorExperiment/bin/Debug/staging/FlashSVGCursorExperiment.ApplicationSprite/web/FlashSVGCursorExperiment.ApplicationSprite.swf contains invalid data.
            //    at FlashSVGCursorExperiment::ApplicationSprite()[V:\web\FlashSVGCursorExperiment\ApplicationSprite.as:34]


            Mouse.registerCursor("c", cursor);
            Mouse.cursor = "c";
        }
        public StarlingGameSpriteBase()
        {
            instance = this;

            gametime.Start();

            this.Content = new Sprite().AttachTo(this);

            this.Content_layer0_ground = new Sprite().AttachTo(this.Content);
            this.Content_layer0_tracks = new Sprite().AttachTo(this.Content);
            this.Content_layer2_shadows = new Sprite().AttachTo(this.Content);
            this.Content_layer3_buildings = new Sprite().AttachTo(this.Content);

            this.Content_layer10_hiddenforgoggles = new Sprite().AttachTo(this.Content);
            this.Content_layer10_hiddenforgoggles.visible = false;

            this.info = new TextField(
                800,
                400,
                "Welcome to Starling!"
                ) { hAlign = HAlign.LEFT, vAlign = VAlign.TOP };


			// i can see text, cannot see images?
			info.AttachTo(this);
            //info.MoveTo(72, 8);





			this.stagescale = internalscale;

            onresize(
                (w, h) =>
                {
                    stagex = w * 0.5;
                    stagey = h * 0.8;
                    stagescale = internalscale * (w) / (800.0);


                }
            );



            #region Source0
            var SourceBitmapData0 = new ScriptCoreLib.ActionScript.flash.display.BitmapData(
                // 28MB
                //64 * 2,
                //64 * 2,

                 // 50 MB
                 2048,
                 2048,
                 true, 0x00000000
            );
            var Source0TextureCount = 0;
            // where to start?
            var Source0TextureTop = 0;
            var Source0TextureLeft = 0;

            // fighting mipmapping
            var Source0Padding = 4;

			// ?
            var Source0 = new XLazy<TextureAtlas>(
                 delegate
                 {
                     var SourceTexture = Texture.fromBitmapData(SourceBitmapData0);
                     var Source = new TextureAtlas(SourceTexture);


                     return Source;
                 }
              );
            #endregion



            #region new_tex_crop
            this.new_tex_crop =
               (asset, alpha, flipx, innersize, adjustAlpha, filter) =>
               {

                   var shape = ScriptCoreLib.ActionScript.Extensions.KnownEmbeddedResources.Default[asset].ToSprite();

                   return new_texsprite_crop(shape, alpha, flipx, innersize, adjustAlpha, filter);
               };


            this.new_texsprite_crop =
               (shape, alpha, flipx, innersize, adjustAlpha, filter) =>
               {


                   //var innersize = 64;
                   // outer 400, inner 64

                   // do we need to wrap?
                   if ((Source0TextureLeft + innersize) >= 2048)
                   {
                       // if so, goto next line
                       Source0TextureTop = Source0TextureMaxBottom;
                       Source0TextureLeft = 0;
                   }

                   var rect = new Rectangle(Source0TextureLeft, Source0TextureTop, innersize, innersize);

                   {

                       if (filter != null)
                           shape.filters = new[] { filter };

                       // this does not work!
                       //shape.alpha = 0.3;



                       // next image will appear right to us + padding to prevent bleed
                       Source0TextureLeft += innersize + Source0Padding;
                       Source0TextureMaxBottom = Source0TextureMaxBottom.Max(Source0TextureTop + innersize + Source0Padding);

                       var m = new Matrix();

                       // flip vertical?
                       if (flipx)
                       {
                           m.translate(-400, 0);
                           m.scale(-1, 1);
                       }

                       m.translate(
                           // where to draw? we need packer algorithm?
                           -(400 - rect.width) / 2 + rect.left,
                           -(400 - rect.height) / 2 + rect.top
                      );



                       // http://stackoverflow.com/questions/8035717/actionscript-3-draw-with-transparency-on-a-bitmap

                       if (adjustAlpha == null)
                           adjustAlpha = new ColorTransform();

                       adjustAlpha.alphaMultiplier = alpha;


                       // public void draw(IBitmapDrawable source, Matrix matrix, ColorTransform colorTransform, string blendMode, Rectangle clipRect);
                       //SourceBitmapData0.draw(shape, m, adjustAlpha, clipRect: rect);
                       SourceBitmapData0.draw(shape, m, adjustAlpha, null, rect);
                   }

                   var TextureIndex = Source0TextureCount;

                   Source0TextureCount++;

                   // Error	5	Cannot convert anonymous method to type 'FlashHeatZeeker.UnitPed.Library.Lazy<starling.textures.TextureAtlas>' because it is not a delegate type	X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.UnitPed\Library\StarlingGameSpriteWithPed.cs	178	43	FlashHeatZeeker.UnitPed
                   var y = new XLazy<TextureAtlas>(
                       delegate
                       {
                           Source0.Content.addRegion(TextureIndex.ToString(), rect);

                           return Source0.Content;
                       }
                    );


                   // ???
                   return () => y.Content.getTexture(TextureIndex.ToString());
               };
            #endregion


            #region new_tex96
            this.new_tex96 =
               (shape, innersize) =>
               {

                   // outer 400, inner 64

                   // do we need to wrap?
                   if ((Source0TextureLeft + innersize) >= 2048)
                   {
                       // if so, goto next line
                       Source0TextureTop = Source0TextureMaxBottom;
                       Source0TextureLeft = 0;
                   }

                   var rect = new Rectangle(Source0TextureLeft, Source0TextureTop, innersize, innersize);

                   {

                       // this does not work!
                       //shape.alpha = 0.3;



                       // next image will appear right to us
                       Source0TextureLeft += innersize + Source0Padding;
                       Source0TextureMaxBottom = Source0TextureMaxBottom.Max(Source0TextureTop + innersize + Source0Padding);

                       var m = new Matrix();
                       m.translate(
                           // where to draw? we need packer algorithm?
                           rect.left,
                           rect.top
                      );

                       //m.scale(64 / 400.0, 64 / 400.0);

                       // http://stackoverflow.com/questions/8035717/actionscript-3-draw-with-transparency-on-a-bitmap

                       var adjustAlpha = new ColorTransform();
                       adjustAlpha.alphaMultiplier = alpha;


                       SourceBitmapData0.draw(shape, m, adjustAlpha);
                   }

                   var TextureIndex = Source0TextureCount;

                   Source0TextureCount++;

                   // Error	5	Cannot convert anonymous method to type 'FlashHeatZeeker.UnitPed.Library.Lazy<starling.textures.TextureAtlas>' because it is not a delegate type	X:\jsc.svn\examples\actionscript\svg\FlashHeatZeeker\FlashHeatZeeker.UnitPed\Library\StarlingGameSpriteWithPed.cs	178	43	FlashHeatZeeker.UnitPed
                   var y = new XLazy<TextureAtlas>(
                       delegate
                       {
                           Source0.Content.addRegion(TextureIndex.ToString(), rect);

                           return Source0.Content;
                       }
                    );

                   return () => y.Content.getTexture(TextureIndex.ToString());
               };
            #endregion


            //var __bmd = new ScriptCoreLib.ActionScript.flash.display.BitmapData(96, 96, true, 0x00000000);
            //__bmd.draw(new white_jsc());
            var LogoTexture = new_tex96(new white_jsc());

            onbeforefirstframe += delegate
            {
                //var count = 64;
                var count = DefaultLogoCount;

                for (int i = 0; i < count; i++)
                    for (int yi = 0; yi < count; yi++)
                    {
                        var logo = new Image(LogoTexture()) { }.AttachTo(Content);

                        {
                            var cm = new Matrix();
                            cm.rotate(random.NextDouble() * Math.PI);
                            cm.translate(i * 96, yi * 96);

                            logo.transformationMatrix = cm;
                        }
                    }
            };


            // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display3D/Context3D.html#driverInfo
            //Text = Starling.current.context.driverInfo;
            Text = "driverInfo missing";


            // how expensive is delegate call in a frame?
            onframe +=
                (stage, starling) =>
                {
                    if (this.frameid == 0)
                    {
                        if (this.onbeforefirstframe != null)
                            this.onbeforefirstframe(stage, starling);
                    }

                    this.frameid++;


                    if (!this.DisableDefaultContentDransformation)
                    {
                        var cm = new Matrix();
                        cm.scale(stagescale, stagescale);

                        if (autorotate)
                            cm.rotate(this.gametime.ElapsedMilliseconds * 0.001);

                        cm.translate(stagex, stagey);
                        this.Content.transformationMatrix = cm;
                    }


                    // does this cost us 40FPS??
                    //var texmem = (this.Source0TextureMaxBottom * 100 / 2048) + "%";

                    //this.info.text = new { this.frameid, texmem, this.Text }.ToString();

                };
        }