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(); }; }
public Game() { #region screen bg { var bmd = new ScriptCoreLib.ActionScript.flash.display.BitmapData(2048, 2048, false, 0xA26D41); var tex = Texture.fromBitmapData(bmd); var img = new Image(tex); addChild(img); } #endregion var viewport_loc = new Sprite().AttachTo(this); var viewport_rot = new Sprite().AttachTo(viewport_loc); var viewport_content = new Sprite().AttachTo(viewport_rot); viewport_rot.scaleX = 2.0; viewport_rot.scaleY = 2.0; // our map { // ArgumentError: Error #3683: Texture too big (max is 2048x2048). var bmd = new ScriptCoreLib.ActionScript.flash.display.BitmapData(2048, 2048, false, 0xB27D51); var tex = Texture.fromBitmapData(bmd); var img = new Image(tex); img.AttachTo(viewport_content); } var viewport_content_layer0 = new Sprite().AttachTo(viewport_content); KnownEmbeddedResources.Default["assets/FlashHeatZeekerWithStarling/touchdown.svg"].ToSprite().With( shape => { var bmd = new ScriptCoreLib.ActionScript.flash.display.BitmapData(400, 400, true, 0x00000000); bmd.draw(shape); var tex = Texture.fromBitmapData(bmd); var img = new Image(tex); img.x = 0; img.y = 0; img.AttachTo(viewport_content); } ); KnownEmbeddedResources.Default["assets/FlashHeatZeekerWithStarling/hill0.svg"].ToSprite().With( shape => { var bmd = new ScriptCoreLib.ActionScript.flash.display.BitmapData(400, 400, true, 0x00000000); bmd.draw(shape); var tex = Texture.fromBitmapData(bmd); var img = new Image(tex); img.x = 400; img.y = 400; img.AttachTo(viewport_content); } ); #region new_tex Func <string, Texture> new_tex = asset => { var shape = KnownEmbeddedResources.Default[asset].ToSprite(); var bmd = new ScriptCoreLib.ActionScript.flash.display.BitmapData(400, 400, true, 0x00000000); bmd.draw(shape); return(Texture.fromBitmapData(bmd)); }; #endregion var textures_bullet = new_tex("assets/FlashHeatZeekerWithStarling/bullet.svg"); var textures_tracks0 = new_tex("assets/FlashHeatZeekerWithStarling/tracks0.svg"); var textures_greentank = new_tex("assets/FlashHeatZeekerWithStarling/greentank.svg"); var textures_greentank_guntower = new_tex("assets/FlashHeatZeekerWithStarling/greentank_guntower.svg"); var textures_greentank_guntower_rank = new_tex("assets/FlashHeatZeekerWithStarling/greentank_guntower_rank.svg"); var textures_greentank_shadow = new_tex("assets/FlashHeatZeekerWithStarling/greentank_shadow.svg"); GameUnit current = null; #region new_gameunit Func <GameUnit> new_gameunit = delegate { var unit_loc = new Sprite().AttachTo(viewport_content); var unit_shadow_loc = new Sprite().AttachTo(unit_loc).MoveTo(8, 8); var unit_shadow_rot = new Sprite().AttachTo(unit_shadow_loc); var shadow_shape = new Image(textures_greentank_shadow) { x = -200, y = -200 }.AttachTo(unit_shadow_rot); shadow_shape.alpha = 0.2; var unit_rot = new Sprite().AttachTo(unit_loc); var shape = new Image(textures_greentank) { x = -200, y = -200 }.AttachTo(unit_rot); var guntower = new Sprite().AttachTo(unit_rot); new Image(textures_greentank_guntower) { x = -200, y = -200 }.AttachTo(guntower); return(new GameUnit { loc = unit_loc, rot = unit_rot, shape = shape, shadow_rot = unit_shadow_rot, AddRank = delegate { new Image(textures_greentank_guntower_rank) { x = -200, y = -200 }.AttachTo(guntower); } }); }; #endregion var unit1 = new_gameunit(); unit1.loc.MoveTo(200, 200); unit1.AddRank(); var unit2 = new_gameunit(); unit2.loc.MoveTo(200 + 400, 200 + 400); var unit3 = new_gameunit(); unit3.loc.MoveTo(200 + 400 + 200, 200 + 400); var controllable = new[] { unit1, unit2, unit3 }; current = unit1; #region tree0 KnownEmbeddedResources.Default["assets/FlashHeatZeekerWithStarling/tree0.svg"].ToSprite().With( shape => { var bmd = new ScriptCoreLib.ActionScript.flash.display.BitmapData(400, 400, true, 0x00000000); bmd.draw(shape); var tex = Texture.fromBitmapData(bmd); for (int iy = 0; iy < 128; iy++) { { var svg = new Image(tex); svg.x = 400; svg.y = 0; svg.AttachTo(viewport_content); svg.scaleX = 0.2; svg.scaleY = 0.2; if (iy % 3 == 0) { svg.y += 50; } if (iy % 3 == 1) { svg.y += 100; } svg.x += 15 * iy; } { var svg = new Image(tex); svg.x = 0; svg.y = 400; svg.AttachTo(viewport_content); svg.scaleX = 0.2; svg.scaleY = 0.2; if (iy % 3 == 0) { svg.x += 50; } if (iy % 3 == 1) { svg.x += 100; } svg.y += 15 * iy; } } } ); #endregion var frameid = 0L; var move_speed = 0.09; var move_forward = 0.0; var move_backward = 0.0; var rot_left = 0.0; var rot_right = 0.0; var rot_sw = new Stopwatch(); rot_sw.Start(); var move_zoom = 1.0; var diesel2 = KnownEmbeddedResources.Default["assets/FlashHeatZeekerWithStarling/diesel4.mp3"].ToSoundAsset().ToMP3PitchLoop(); //diesel2.Sound.vol var KineticEnergy = new List <KineticEnergy>(); ApplicationSprite.__stage.enterFrame += delegate { // which is it, do we need to zoom out or in? #region KineticEnergy foreach (var item in KineticEnergy) { item.Target.With( t => { if (item.TTL == 0) { t.Orphanize(); item.Target = null; return; } t.x += rot_sw.ElapsedMilliseconds * item.Energy.x; t.y += rot_sw.ElapsedMilliseconds * item.Energy.y; item.TTL--; } ); } #endregion var any_movement = Math.Sign( Math.Abs(move_forward) + Math.Abs(move_backward) + Math.Abs(rot_left) + Math.Abs(rot_right) ) - 0.5; move_zoom += any_movement * rot_sw.ElapsedMilliseconds * 0.004; move_zoom = move_zoom.Max(0.0).Min(1.0); diesel2.LeftVolume = 0.3 + move_zoom * 0.7; diesel2.Rate = 0.9 + move_zoom; // show only % of the zoom/speed boost viewport_rot.scaleX = 1 + (1 - move_zoom) * 0.2; viewport_rot.scaleY = 1 + (1 - move_zoom) * 0.2; var drot = rot_sw.ElapsedMilliseconds * (1 + move_zoom) * (rot_left + rot_right) * (Math.Abs(move_forward + move_backward).Max(0.5) * 0.09).DegreesToRadians(); var dx = rot_sw.ElapsedMilliseconds * (1 + move_zoom) * (move_forward + move_backward) * move_speed * Math.Cos(-viewport_rot.rotation + (270).DegreesToRadians()); var dy = rot_sw.ElapsedMilliseconds * (1 + move_zoom) * (move_forward + move_backward) * move_speed * Math.Sin(-viewport_rot.rotation + (270).DegreesToRadians()); current.With( c => { c.rotation += drot; var prevframe_loc = new __vec2(); prevframe_loc.x = (float)c.loc.x; prevframe_loc.y = (float)c.loc.y; c.loc.x += dx; c.loc.y += dy; var prevframe_loc_length = new __vec2( c.prevframe_loc.x - (float)c.loc.x, c.prevframe_loc.y - (float)c.loc.y ).GetLength(); var changed_prevframe_rot = Math.Abs(c.rot.rotation - c.prevframe_rot) > 25.DegreesToRadians(); if (prevframe_loc_length > 80 || changed_prevframe_rot) { // unit draws tracks.. c.prevframe_loc = prevframe_loc; c.prevframe_rot = c.rot.rotation; var unit_loc = new Sprite().AttachTo(viewport_content_layer0); var unit_rot = new Sprite().AttachTo(unit_loc); var img = new Image(textures_tracks0); img.x = -200; img.y = -200; img.alpha = 0.2; img.AttachTo(unit_rot); unit_rot.rotation = current.rot.rotation; unit_loc.MoveTo(current.loc.x, current.loc.y); c.tracks.Enqueue(unit_loc); if (c.tracks.Count > 96) { c.tracks.Dequeue().Orphanize(); } } } ); viewport_rot.rotation -= drot; viewport_content.x -= dx; viewport_content.y -= dy; rot_sw.Restart(); }; // script: error JSC1000: ActionScript : failure at starling.display.Stage.add_keyDown : Object reference not set to an instance of an object. // there is something fron with flash natives gen. need to fix that. ApplicationSprite.__stage.keyDown += e => { Console.WriteLine("keyDown " + new { e.keyCode }); if (e.keyCode == (uint)System.Windows.Forms.Keys.Up) { move_forward = 1; } if (e.keyCode == (uint)System.Windows.Forms.Keys.Down) { // move slower while backwards? move_backward = -0.5; } if (e.keyCode == (uint)System.Windows.Forms.Keys.Left) { rot_left = -1; } if (e.keyCode == (uint)System.Windows.Forms.Keys.Right) { rot_right = 1; } }; Action <GameUnit> switchto = nextunit => { KnownEmbeddedResources.Default["assets/FlashHeatZeekerWithStarling/letsgo.mp3"].ToSoundAsset().play(); move_zoom = 1; current = nextunit; viewport_rot.rotation = -current.rot.rotation; viewport_content.x = -current.loc.x; viewport_content.y = -current.loc.y; }; ApplicationSprite.__stage.keyUp += e => { Console.WriteLine("keyUp " + new { e.keyCode }); if (e.keyCode == (uint)System.Windows.Forms.Keys.Up) { move_forward = 0; } if (e.keyCode == (uint)System.Windows.Forms.Keys.Down) { move_backward = 0; } if (e.keyCode == (uint)System.Windows.Forms.Keys.Left) { rot_left = 0; } if (e.keyCode == (uint)System.Windows.Forms.Keys.Right) { rot_right = 0; } if (e.keyCode == (uint)System.Windows.Forms.Keys.D1) { switchto(unit1); } if (e.keyCode == (uint)System.Windows.Forms.Keys.D2) { switchto(unit2); } if (e.keyCode == (uint)System.Windows.Forms.Keys.D3) { switchto(unit3); } if (e.keyCode == (uint)System.Windows.Forms.Keys.Tab) { // System.Linq.Enumerable for System.Collections.Generic.IEnumerable`1[FlashHeatZeekerWithStarling.GameUnit] Skip[GameUnit](System.Collections.Generic.IEnumerable`1[FlashHeatZeekerWithStarling.GameUnit], Int32) used at //FlashHeatZeekerWithStarling.Game+<>c__DisplayClass10.<.ctor>b__a at offset 014b. //If the use of this method is intended, an implementation should be provided with the attribute [Script(Implements=typeof(...)] set. You may have mistyped it. var nextunit = controllable.AsCyclicEnumerable().SkipWhile(k => k != current).Take(2).Last(); switchto(nextunit); } if (e.keyCode == (uint)System.Windows.Forms.Keys.ControlKey) { Console.WriteLine("fire!"); // http://www.sounddogs.com/results.asp?Type=1&CategoryID=1027&SubcategoryID=11 KnownEmbeddedResources.Default["assets/FlashHeatZeekerWithStarling/cannon1.mp3"].ToSoundAsset().play(); var unit_bullet = new Sprite().AttachTo(viewport_content); var shape = new Image(textures_bullet) { x = -200, y = -200 }.AttachTo(unit_bullet); unit_bullet.MoveTo( current.loc.x + 100 * Math.Cos(current.rotation + 270.DegreesToRadians()), current.loc.y + 100 * Math.Sin(current.rotation + 270.DegreesToRadians()) ); KineticEnergy.Add( new FlashHeatZeekerWithStarling.KineticEnergy { Target = unit_bullet, Energy = new __vec2( (float)(2 * Math.Cos(current.rotation + 270.DegreesToRadians())), (float)(2 * Math.Sin(current.rotation + 270.DegreesToRadians())) ), TTL = 100 } ); unit_bullet.scaleX = 0.8; unit_bullet.scaleY = 0.8; } }; // where is our ego? center of touchdown? viewport_content.x = -200; viewport_content.y = -200; var info = new TextField(100, 200, "Welcome to Starling!"); info.width = 400; addChild(info); var __bmd = new ScriptCoreLib.ActionScript.flash.display.BitmapData(96, 96, true, 0x00000000); __bmd.draw(new white_jsc()); var __img = Texture.fromBitmapData(__bmd); var logo = new Image(__img) { alpha = 0.3 }.AttachTo(this); #region viewport_loc, resize all you want Action centerize = delegate { logo.MoveTo( ApplicationSprite.__stage.stageWidth - 96, ApplicationSprite.__stage.stageHeight - 96 ); viewport_loc.x = ApplicationSprite.__stage.stageWidth * 0.5; viewport_loc.y = ApplicationSprite.__stage.stageHeight * 0.7; }; ApplicationSprite.__stage.resize += delegate { centerize(); }; centerize(); #endregion var maxframe = new Stopwatch(); var maxframe_elapsed = 0.0; #region fps var sw = new Stopwatch(); sw.Start(); var fps = 1; var ii = 0; maxframe.Start(); ApplicationSprite.__stage.enterFrame += delegate { frameid++; maxframe.Stop(); // System.TimeSpan for Boolean op_GreaterThan(System.TimeSpan, System.TimeSpan) used at //FlashHeatZeeker.ApplicationSprite+<>c__DisplayClass11.<.ctor>b__d at offset 001e. // TypeError: Error #1009: Cannot access a property or method of a null object reference. //at FlashHeatZeeker::ApplicationSprite___c__DisplayClass11/__ctor_b__d_100663322()[U:\web\FlashHeatZeeker\ApplicationSprite___c__DisplayClass11.as:141] if (maxframe.Elapsed.TotalMilliseconds > maxframe_elapsed) { maxframe_elapsed = maxframe.Elapsed.TotalMilliseconds; } ii++; var now = DateTime.Now; info.text = new { fps, frameid, maxframe_elapsed, now }.ToString(); if (sw.ElapsedMilliseconds < 1000) { maxframe.Restart(); return; } fps = ii; ApplicationSprite.__sprite.raise_fps("" + fps); ii = 0; maxframe_elapsed = 0; sw.Restart(); }; #endregion }
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(); }; }