public StarlingGameSpriteWithCannonTextures(Texture64Constructor new_tex_crop) { tracergun_guntower = new_tex_crop("assets/FlashHeatZeeker.UnitCannon/tracergun_guntower.svg", innersize: 128); tracergun_guntower_shadow = new_tex_crop("assets/FlashHeatZeeker.UnitCannon/tracergun_guntower_shadow.svg", innersize: 128, alpha: 0.15); tracergun_mount = new_tex_crop("assets/FlashHeatZeeker.UnitCannon/tracergun_mount.svg", innersize: 128); }
public StarlingGameSpriteWithRocketTextures(Texture64Constructor new_tex_crop) { //DRW 3 smoke1 = new_tex_crop("assets/FlashHeatZeeker.UnitRocket/smoke1.svg", innersize: 128, alpha: 0.8); rocket1 = new_tex_crop("assets/FlashHeatZeeker.UnitRocket/rocket1.svg", innersize: 128); rocket1_burn1 = new_tex_crop("assets/FlashHeatZeeker.UnitRocket/rocket1_burn1.svg", innersize: 128); rocket1_burn2 = new_tex_crop("assets/FlashHeatZeeker.UnitRocket/rocket1_burn2.svg", innersize: 128); }
public StarlingGameSpriteWithHindTextures(Texture64Constructor new_tex_crop) { hind0_nowings = new_tex_crop("assets/FlashHeatZeeker.UnitHind/hind0_nowings.svg", innersize: 320); hind0_shadow = new_tex_crop("assets/FlashHeatZeeker.UnitHind/hind0_shadow.svg", innersize: 320, alpha: 0.15); hind0_wing1shadow = new_tex_crop("assets/FlashHeatZeeker.UnitHind/hind0_wing1shadow.svg", innersize: 320, alpha: 0.07); hind0_wing1 = new_tex_crop("assets/FlashHeatZeeker.UnitHind/hind0_wing1.svg", innersize: 320); hind0_wing2 = new_tex_crop("assets/FlashHeatZeeker.UnitHind/hind0_wing1.svg", innersize: 320, alpha: 0.4); hind0_wing3 = new_tex_crop("assets/FlashHeatZeeker.UnitHind/hind0_wing1.svg", innersize: 320, alpha: 0.2); }
public StarlingGameSpriteWithJeepTextures(Texture64Constructor new_tex_crop) { // http://forum.starling-framework.org/topic/confirmation-on-optimum-quadbatch-use // hack, Quad should do the work, yet it drags performance! black4 = new_tex_crop("assets/FlashHeatZeeker.UnitJeep/jeep_shadow.svg", innersize: 4); jeep = new_tex_crop("assets/FlashHeatZeeker.UnitJeep/jeep.svg"); jeep_shadow = new_tex_crop("assets/FlashHeatZeeker.UnitJeep/jeep_shadow.svg", alpha: 0.3); jeep_trackpattern = new_tex_crop("assets/FlashHeatZeeker.UnitJeep/jeep_trackpattern.svg", alpha: 0.2); jeep_trackpattern_semi = new_tex_crop("assets/FlashHeatZeeker.UnitJeep/jeep_trackpattern.svg", alpha: 0.04); }
public StarlingGameSpriteWithMapTextures(Texture64Constructor new_tex_crop) { tree0 = new_tex_crop("assets/FlashHeatZeeker.CoreMap/tree0.svg", innersize: 256); tree0_shadow = new_tex_crop("assets/FlashHeatZeeker.CoreMap/tree0_shadow.svg", innersize: 256, alpha: 0.3); hill1 = new_tex_crop("assets/FlashHeatZeeker.CoreMap/hill1.svg", innersize: 256); hole1 = new_tex_crop("assets/FlashHeatZeeker.CoreMap/hole1.svg", innersize: 256); grass1 = new_tex_crop("assets/FlashHeatZeeker.CoreMap/grass1.svg", innersize: 256); road0 = new_tex_crop("assets/FlashHeatZeeker.CoreMap/road0.svg", innersize: 256); touchdown = new_tex_crop("assets/FlashHeatZeeker.CoreMap/touchdown.svg", innersize: 256); }
public StarlingGameSpriteWithBunkerTextures(Texture64Constructor new_tex_crop) { bunker2 = new_tex_crop("assets/FlashHeatZeeker.UnitBunkerControl/bunker2.svg", innersize: 256); bunker2_shadow = new_tex_crop("assets/FlashHeatZeeker.UnitBunkerControl/bunker2_shadow.svg", innersize: 267, alpha: 0.3); bunker2_shopoverlay = new_tex_crop("assets/FlashHeatZeeker.UnitBunkerControl/bunker2_shopoverlay.svg", innersize: 256); bunker2_shopoverlay_arrow = new_tex_crop("assets/FlashHeatZeeker.UnitBunkerControl/bunker2_shopoverlay_arrow.svg", innersize: 256); barrel1 = new_tex_crop("assets/FlashHeatZeeker.UnitBunkerControl/barrel1.svg", innersize: 192); barrel1_shadow = new_tex_crop("assets/FlashHeatZeeker.UnitBunkerControl/barrel1_shadow.svg", innersize: 192, alpha: 0.3); silo1 = new_tex_crop("assets/FlashHeatZeeker.UnitBunkerControl/silo1.svg", innersize: 192); silo1_shadow = new_tex_crop("assets/FlashHeatZeeker.UnitBunkerControl/silo1_shadow.svg", innersize: 192, alpha: 0.2); watertower0 = new_tex_crop("assets/FlashHeatZeeker.UnitBunkerControl/watertower0.svg", innersize: 192); watertower0_shadow = new_tex_crop("assets/FlashHeatZeeker.UnitBunkerControl/watertower0_shadow.svg", innersize: 192, alpha: 0.6); }
public StarlingGameSpriteWithPedTextures( Texture64Constructor new_tex_crop, SpriteToTexture64Constructor new_texsprite_crop ) { //DRW 3 hud_look = new_texsprite_crop(new hud_look(), innersize: 128); hud_look_building = new_texsprite_crop(new hud_look_building(), innersize: 128); hud_look_goggles = new_texsprite_crop(new hud_look_goggles(), innersize: 128); hud_look_onlygoggles = new_texsprite_crop(new hud_look_onlygoggles(), innersize: 128); ped_shadow = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_shadow.svg", alpha: 0.3, innersize: 96); ped_footprints = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_footprints.svg", 0.07); var r = 0.2225; var g = 0.7169; var b = 0.0606; // http://blog.slapthink.net/2008/12/24/desaturategreyscale-a-movieclip-in-as3/ var ped_walkzombie_filter = new ScriptCoreLib.ActionScript.flash.filters.ColorMatrixFilter( r, g, b, 0, 0, r, g, b, 0, 0, r, g, b, 0, 0, 0, 0, 0, 1, 0 ); ped_walkzombie = new WalkFrames { ped_down = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_down.svg", innersize: 128, filter: ped_walkzombie_filter), ped_stand = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_stand.svg", innersize: 128, filter: ped_walkzombie_filter), ped_gunstand = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_gunstand.svg", innersize: 128, filter: ped_walkzombie_filter), ped_gunstand_fire = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_gunstand_fire.svg", innersize: 128), // left foot ped_walk1_leftfar = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_stand_walk1.svg", innersize: 128, filter: ped_walkzombie_filter), ped_walk2_leftmid = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_stand_walk2.svg", innersize: 128, filter: ped_walkzombie_filter), ped_walk3_leftclose = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_stand_walk3.svg", innersize: 128, filter: ped_walkzombie_filter), ped_walk1x_rightfar = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_stand_walk1.svg", flipx: true, innersize: 128, filter: ped_walkzombie_filter), ped_walk2x_rightmid = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_stand_walk2.svg", flipx: true, innersize: 128, filter: ped_walkzombie_filter), ped_walk3x_rightclose = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_stand_walk3.svg", flipx: true, innersize: 128, filter: ped_walkzombie_filter) }; ped_walk = new WalkFrames { ped_down = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_down.svg", innersize: 128), ped_stand = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_normalstand.svg", innersize: 128), ped_gunstand = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_gunstand.svg", innersize: 128), ped_gunstand_fire = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_gunstand_fire.svg", innersize: 128), // left foot ped_walk1_leftfar = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_normalstand_walk1.svg", innersize: 128), ped_walk2_leftmid = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_normalstand_walk2.svg", innersize: 128), ped_walk3_leftclose = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_normalstand_walk3.svg", innersize: 128), ped_walk1x_rightfar = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_normalstand_walk1.svg", flipx: true, innersize: 128), ped_walk2x_rightmid = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_normalstand_walk2.svg", flipx: true, innersize: 128), ped_walk3x_rightclose = new_tex_crop("assets/FlashHeatZeeker.UnitPed/ped_normalstand_walk3.svg", flipx: true, innersize: 128) }; }
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(); }; }