public override void onAddedToScene() { normalButtonSubtexture = new Subtexture(scene.content.Load <Texture2D>(normalButtonContent)); hoverButtonSubtexture = new Subtexture(scene.content.Load <Texture2D>(hoverButtonContent)); buttonSprite = new Sprite(normalButtonSubtexture); addComponent(buttonSprite); }
public FrameInfo(Subtexture subtexture, int offsetX, int offsetY) { Subtexture = subtexture; AttackColliders = new List <AttackCollider>(); OffsetX = offsetX; OffsetY = offsetY; }
public PlayerPanelHUD(Player player, int screenX, int screenY) { _player = player; var hudTexture = AssetLoader.GetTexture("UI/HUD"); var hudFrontTexture = new Subtexture(hudTexture, 0, 0, 48, 16); var bar = new Subtexture(hudTexture, 48, 0, _barTextureWidth, 3); _panel = new ScalableSprite(hudFrontTexture); _panel.renderLayer = Layers.HUD; _panel.layerDepth = 1f; _panel.localOffset = new Vector2(screenX + 48, screenY); _panel.origin = new Vector2(0, 0); _healthBar = new ScalableSprite(bar); _healthBar.color = Color.Green; _healthBar.localOffset = _panel.localOffset + new Vector2(80, 28); _healthBar.renderLayer = Layers.HUD; _healthBar.origin = new Vector2(0, 0); _healthBarFade = new ScalableSprite(bar); _healthBarFade.color = Color.OrangeRed; _healthBarFade.localOffset = _panel.localOffset + new Vector2(80, 28); _healthBarFade.renderLayer = Layers.HUD; _healthBarFade.layerDepth = 0.5f; _healthBarFade.origin = new Vector2(0, 0); _staminaBar = new ScalableSprite(bar); _staminaBar.color = Color.Red; _staminaBar.localOffset = _panel.localOffset + new Vector2(80, 44); _staminaBar.renderLayer = Layers.HUD; _staminaBar.origin = new Vector2(0, 0); _staminaBarFade = new ScalableSprite(bar); _staminaBarFade.color = Color.OrangeRed; _staminaBarFade.localOffset = _panel.localOffset + new Vector2(80, 44); _staminaBarFade.renderLayer = Layers.HUD; _staminaBarFade.layerDepth = 0.5f; _staminaBarFade.origin = new Vector2(0, 0); _head = new ScalableSprite(bar); _head.renderLayer = Layers.HUD; _head.layerDepth = 1f; _head.localOffset = _panel.localOffset + new Vector2(40, 50); _head.origin = new Vector2(0, 0); _panel.SetScale(new Vector2(_uiScale, _uiScale)); _head.SetScale(new Vector2(_uiScale, _uiScale)); _healthBar.SetScale(new Vector2((_uiScale + BarStretchToFit) * _healthBarScale, _uiScale)); _healthBarFade.SetScale(new Vector2((_uiScale + BarStretchToFit) * _healthBarFadeScale, _uiScale)); _staminaBar.SetScale(new Vector2((_uiScale + BarStretchToFit) * _staminaBarScale, _uiScale)); _staminaBarFade.SetScale(new Vector2((_uiScale + BarStretchToFit) * _staminaBarFadeScale, _uiScale)); addComponent(_panel); addComponent(_healthBar); addComponent(_healthBarFade); addComponent(_staminaBar); addComponent(_staminaBarFade); addComponent(_head); }
public static Nez.BitmapFonts.BitmapFont NezBitmapFromBakedTTF(SpriteFontPlus.TtfFontBakerResult ttf) { var rgb = new Color[ttf.Width * ttf.Height]; for (var i = 0; i < ttf.Pixels.Length; ++i) { var b = ttf.Pixels[i]; rgb[i].R = b; rgb[i].G = b; rgb[i].B = b; rgb[i].A = b; } var texture = new Texture2D(Core.graphicsDevice, ttf.Width, ttf.Height); texture.SetData(rgb); var regions = new BitmapFonts.BitmapFontRegion[ttf.Glyphs.Count]; var index = 0; var orderedKeys = ttf.Glyphs.Keys.OrderBy(a => a); foreach (var key in orderedKeys) { var character = ttf.Glyphs[key]; var bounds = new Rectangle(character.X, character.Y, character.Width, character.Height); var subtexture = new Subtexture(texture, bounds); var region = new BitmapFonts.BitmapFontRegion(subtexture, (char)key, character.XOffset, character.YOffset, character.XAdvance); regions[index++] = region; } return(new Nez.BitmapFonts.BitmapFont(regions, ttf.Height)); }
private Subtexture recreateSubtextureWithRate(Subtexture subtexture, float rate) { var r = subtexture.sourceRect; r.Width = (int)(subtexture.texture2D.Width * rate); return(new Subtexture(subtexture.texture2D, r)); }
public GameBoard(RemoteGameState gameState) { this.gameState = gameState; var tileTexture = GlintCore.contentSource.Load <Texture2D>("Sprites/Game/tile"); unknownTileSubtex = new Subtexture(tileTexture, new Rectangle(0, 0, TILE_TEXTURE_SIZE, TILE_TEXTURE_SIZE)); baseTileSubtex = new Subtexture(tileTexture, new Rectangle(TILE_TEXTURE_SIZE, 0, TILE_TEXTURE_SIZE, TILE_TEXTURE_SIZE)); propertyTileSubtex = new Subtexture(tileTexture, new Rectangle(0, TILE_TEXTURE_SIZE, TILE_TEXTURE_SIZE, TILE_TEXTURE_SIZE)); highlightedTileSubtex = new Subtexture(tileTexture, new Rectangle(TILE_TEXTURE_SIZE, TILE_TEXTURE_SIZE, TILE_TEXTURE_SIZE, TILE_TEXTURE_SIZE)); var tileDisplayTexture = GlintCore.contentSource.Load <Texture2D>("Sprites/Game/tile_display"); tileDisplayActiveSubtex = new Subtexture(tileDisplayTexture, new Rectangle(0, 0, TILE_TEXTURE_SIZE, TILE_TEXTURE_SIZE)); tileDisplayTargetSubtex = new Subtexture(tileDisplayTexture, new Rectangle(TILE_TEXTURE_SIZE, 0, TILE_TEXTURE_SIZE, TILE_TEXTURE_SIZE)); var stationsTexture = GlintCore.contentSource.Load <Texture2D>("Sprites/Game/station"); stationSubtexes = Subtexture.subtexturesFromAtlas(stationsTexture, TILE_TEXTURE_SIZE, TILE_TEXTURE_SIZE); var pawnsTexture = GlintCore.contentSource.Load <Texture2D>("Sprites/Game/pawns"); pawnSubtexes = Subtexture.subtexturesFromAtlas(pawnsTexture, TILE_TEXTURE_SIZE, TILE_TEXTURE_SIZE); }
private static void addGetSpiderButton(Dialog dialog, Player interactor, Entity interactable, Skin skin) { var textureAtlas = interactor.scene.content.Load <Texture2D>("Characters/Spider"); var subtexture = Subtexture.subtexturesFromAtlas(textureAtlas, 16, 16); Button pet1 = new Button(skin); Image i = new Image(subtexture[0]); pet1.add(i); var c = pet1.getCell(i); c.setMinHeight(c.getMinHeight() * 5); c.setMinWidth(c.getMinWidth() * 5); pet1.row(); pet1.add("Crangly Crawler"); pet1.onClicked += getButt => { BaseMungus pet = new Spider("spiderman", interactor.position); interactor.pet = pet; interactor.scene.addEntity(pet); interactable.getComponent <EntityMover>().resumeMovement(); interactor.enableActions(); dialog.remove(); }; dialog.add(pet1); }
public SpriteAnimation ToSpriteAnimation(string source, int tileWidth = 32, int tileHeight = 32) { if (FPS <= 0) { throw new System.Exception("Sorry bro, FPS must be biggur than 0"); } if (Frames?.Length <= 0) { throw new System.Exception("Sorry bro, not enough frames"); } var texture = AssetLoader.GetTexture(source); var subtextures = Subtexture.subtexturesFromAtlas(texture, tileWidth, tileHeight); if (Origin.Length() != 0) { subtextures.ForEach(t => t.origin = Origin); } var frames = Frames .Select(i => subtextures[i]) .ToList(); var animation = new SpriteAnimation { frames = frames, loop = Loop, fps = FPS }; return(animation); }
public static void ApplyButtonImage(string widgetName, string normalSubtexture, string clickedSubtexture) // Метод применения текстуры кнопокам из файлов { if (File.Exists(normalSubtexture)) { using (FileStream fs = new FileStream(normalSubtexture, FileMode.Open, FileAccess.Read, FileShare.Read)) { Subtexture subtexture = new Subtexture(Texture2D.Load(fs), Vector2.Zero, Vector2.One); ScreensManager.CurrentScreen.ScreenWidget.FindWidget <BitmapButtonWidget>(widgetName, true).NormalSubtexture = subtexture; fs.Close(); } } else { Log.Warning("Subtexture " + normalSubtexture + " not found!"); } if (File.Exists(clickedSubtexture)) { using (FileStream fs = new FileStream(clickedSubtexture, FileMode.Open, FileAccess.Read, FileShare.Read)) { Subtexture subtexture = new Subtexture(Texture2D.Load(fs), Vector2.Zero, Vector2.One); ScreensManager.CurrentScreen.ScreenWidget.FindWidget <BitmapButtonWidget>(widgetName, true).ClickedSubtexture = subtexture; fs.Close(); } } else { Log.Warning("Subtexture " + clickedSubtexture + " not found!"); } }
public override void Render() { if (base.Scene.OnInterval(5)) { this.flash = !this.flash; } if (this.pad.OwnerIndex != -1) { Subtexture subtexture = TFGame.Atlas ["chaliceBlood"]; int num = (int)MathHelper.Lerp(0f, (float)subtexture.Height, this.pad.FillPercent); if (num > 0) { Color color; if (base.Level.Session.MatchSettings.TeamMode) { TeamData teamData = ArcherData.Get(base.Level.Session.MatchSettings.Teams [this.pad.OwnerIndex]); color = (this.flash ? teamData.ColorB : teamData.ColorA); } else { ArcherData archerData = ArcherData.Get(TFGame.Characters [this.pad.OwnerIndex], ArcherData.ArcherTypes.Normal); color = (this.flash ? archerData.ColorB : archerData.ColorA); } Draw.Texture(subtexture, new Rectangle(0, subtexture.Height - num, subtexture.Width, num), this.Position + new Vector2(-8f, (float)(-40 + subtexture.Height - num)), color); } } this.image.DrawOutline(1); base.Render(); }
public BuildingRenderer(BuildingType buildingType, Building building, Subtexture texture) { this.buildingType = buildingType; this.building = building; this.texture = texture; building.components.Add("renderer", this); }
public Kuratko(Scene defaultScene) { entity = defaultScene.createEntity("entity", new Vector2(50, 50)); _inputHandler = entity.addComponent(new KuratkoInputHandler()); _mover = entity.addComponent(new Mover()); _collider = entity.colliders.add(new CircleCollider()); // ANIMACE var texture = defaultScene.contentManager.Load <Texture2D>("sprites/zviratka"); var subtextures = Subtexture.subtexturesFromAtlas(texture, 32, 32); _animation = entity.addComponent(new Sprite <Animations>(subtextures[8])); _animation.addAnimation(Animations.Default, new SpriteAnimation(new List <Subtexture>() { subtextures[8], })); _animation.addAnimation(Animations.Walk, new SpriteAnimation(new List <Subtexture>() { subtextures[9], subtextures[8], subtextures[16], })); }
public FSCompoundPolygonBody(World world, Subtexture subtexture, float density, Vector2 position = default(Vector2), BodyType bodyType = BodyType.Static) : base(world, subtexture, position, bodyType) { var data = new uint[subtexture.sourceRect.Width * subtexture.sourceRect.Height]; subtexture.texture2D.GetData(0, subtexture.sourceRect, data, 0, data.Length); var verts = PolygonTools.CreatePolygon(data, subtexture.sourceRect.Width); verts = SimplifyTools.DouglasPeuckerSimplify(verts, 2); var decomposedVerts = Triangulate.ConvexPartition(verts, TriangulationAlgorithm.Bayazit); for (var i = 0; i < decomposedVerts.Count; i++) { var polygon = decomposedVerts[i]; polygon.Translate(-subtexture.center); } // add the fixtures var fixtures = Farseer.FixtureFactory.attachCompoundPolygon(decomposedVerts, density, body); // fetch all the Vertices and save a copy in case we need to scale them later foreach (var fixture in fixtures) { _verts.Add(new Vertices((fixture.Shape as PolygonShape).Vertices)); } }
public override void initialize() { base.initialize(); //Load in and add the closedDoor sprite Subtexture closedTex = new Subtexture(scene.content.Load <Texture2D>("Sprites/closedChest")); closedChest.setSubtexture(closedTex); closedChest.setEnabled(true); addComponent(closedChest); closedChest.setRenderLayer(0); closedChest.transform.position = new Vector2(obj.x + obj.width / 2, (obj.y + obj.height / 2)); getCollider <BoxCollider>().setLocalOffset(new Vector2(0, 0)); //Load in and add the openChest sprite //Starts off disabled because the chest starts closed Subtexture tex = new Subtexture(scene.content.Load <Texture2D>("Sprites/OpenChest")); openChest.setSubtexture(tex); openChest.setEnabled(false); addComponent(openChest); openChest.setRenderLayer(0); openChest.transform.position = new Vector2(obj.x + obj.width / 2, (obj.y + obj.height / 2)); getCollider <BoxCollider>().setLocalOffset(new Vector2(0, 0)); }
private List <Subtexture> LoadAttackDown() { Subtexture subtexture = new Subtexture(Texture, new Rectangle(x: 22, y: 131, width: 29, height: 23), new Vector2(32f * 0.65f, 32f * 0.65f)); Subtexture attack0 = new Subtexture(Texture, new Rectangle(x: 57, y: 130, width: 27, height: 30), new Vector2(27f * 0.65f, 30f * 0.53f)); Subtexture attack1 = new Subtexture(Texture, new Rectangle(x: 89, y: 131, width: 23, height: 35), new Vector2(23f * 0.62f, 35f * 0.49f)); Subtexture attack2 = new Subtexture(Texture, new Rectangle(x: 121, y: 132, width: 21, height: 36), new Vector2(21f * 0.47f, 36f * 0.46f)); Subtexture attack3 = new Subtexture(Texture, new Rectangle(x: 150, y: 132, width: 26, height: 35), new Vector2(26f * 0.38f, 35f * 0.46f)); Subtexture attack4 = new Subtexture(Texture, new Rectangle(x: 188, y: 131, width: 29, height: 32), new Vector2(29f * 0.32f, 38f * 0.49f)); Subtexture attack5 = new Subtexture(Texture, new Rectangle(x: 225, y: 130, width: 33, height: 24), new Vector2(33f * 0.27f, 24f * 0.65f)); Subtexture attack6 = new Subtexture(Texture, new Rectangle(x: 264, y: 130, width: 19, height: 24), new Vector2(19f * 0.47f, 24f * 0.65f)); List <Subtexture> attackAnimation = new List <Subtexture>() { subtexture, attack0, attack1, attack2, attack3, attack4, attack5, attack6, //attack7, }; return(attackAnimation); }
public void loadContent() { //Splits spritesheet into subtextures Texture2D texture = entity.scene.content.Load <Texture2D>("Temp/TestPlayerAnimationSheet"); List <Subtexture> subtextures = Subtexture.subtexturesFromAtlas(texture, 16, 32); _animations = entity.addComponent(new Sprite <Animations>(subtextures[0])); //Load animations //Idle animation _animations.addAnimation(Animations.IDLE, new SpriteAnimation(new List <Subtexture>() { subtextures[0], subtextures[1] })); //Run animation _animations.addAnimation(Animations.RUN, new SpriteAnimation(new List <Subtexture>() { subtextures[8], subtextures[9], subtextures[10], subtextures[11] })); }
private void setupAnimations() { var texture = scene.content.Load <Texture2D>("sprites/flames"); var subtextures = Subtexture.subtexturesFromAtlas(texture, 16, 18); animation = addComponent(new Sprite <Animations>(subtextures[0])); animation.addAnimation(Animations.Fuse, new SpriteAnimation(new List <Subtexture>() { subtextures[0] })); animation.addAnimation(Animations.Exploding, new SpriteAnimation(new List <Subtexture>() { subtextures[1], subtextures[2], subtextures[3], subtextures[4], subtextures[5], subtextures[6], subtextures[7], subtextures[8], subtextures[9], subtextures[10], subtextures[11] })); }
public override void initialize() { clearColor = Color.Black; setDesignResolution(640, 368, Scene.SceneResolutionPolicy.ShowAllPixelPerfect); Screen.setSize(1280, 736); // load a TiledMap and move it back so is drawn before other entities var tiledEntity = createEntity("tiled-map"); var tiledmap = content.Load <TiledMap>(Content.DestructableMap.destructablemap); tiledEntity.addComponent(new TiledMapComponent(tiledmap, "main")); var objects = tiledmap.getObjectGroup("objects"); var spawn = objects.objectWithName("spawn"); var ball = objects.objectWithName("ball"); var atlas = content.Load <Texture2D>(Content.DestructableMap.desertpalacetiles2x); var atlasParts = Subtexture.subtexturesFromAtlas(atlas, 16, 16); var playerSubtexture = atlasParts[96]; var playerEntity = createEntity("player"); playerEntity.transform.position = new Vector2(spawn.x + 8, spawn.y + 8); playerEntity.addComponent(new Sprite(playerSubtexture)); playerEntity.addComponent(new PlayerDashMover()); playerEntity.addComponent(new CameraShake()); playerEntity.addComponent(new PolyLight(100) { collidesWithLayers = 1 << 0, color = Color.Yellow * 0.5f }); var trail = playerEntity.addComponent(new SpriteTrail(playerEntity.getComponent <Sprite>())); trail.fadeDelay = 0; trail.fadeDuration = 0.2f; trail.minDistanceBetweenInstances = 10f; trail.initialColor = Color.White * 0.5f; // add a collider and put it on layer 2 but make it only collide with layer 0. This will make the player only collide with the tilemap var collider = playerEntity.addComponent <BoxCollider>(); Flags.setFlagExclusive(ref collider.physicsLayer, 2); Flags.setFlagExclusive(ref collider.collidesWithLayers, 0); // create an object at the location set on our Tiled object layer that only collides with tiles and not the player var ballSubtexture = atlasParts[96]; var ballEntity = createEntity("ball"); ballEntity.transform.position = new Vector2(ball.x + 8, ball.y + 8); ballEntity.addComponent(new Sprite(ballSubtexture)); ballEntity.addComponent(new ArcadeRigidbody()); // add a collider and put it on layer 1. Make it only collide with layer 0 (the tilemap) so it doesnt interact with the player. var circleCollider = ballEntity.addComponent <CircleCollider>(); Flags.setFlagExclusive(ref circleCollider.physicsLayer, 1); Flags.setFlagExclusive(ref circleCollider.collidesWithLayers, 0); }
protected override BitmapFont Read(ContentReader reader, BitmapFont existingInstance) { var totalTextures = reader.ReadInt32(); var textures = new Texture2D[totalTextures]; for (var i = 0; i < totalTextures; i++) { textures[i] = reader.ReadObject <Texture2D>(); } var lineHeight = reader.ReadInt32(); var regionCount = reader.ReadInt32(); var regions = new BitmapFontRegion[regionCount]; for (var r = 0; r < regionCount; r++) { var character = (char)reader.ReadInt32(); var textureIndex = reader.ReadInt32(); var x = reader.ReadInt32(); var y = reader.ReadInt32(); var width = reader.ReadInt32(); var height = reader.ReadInt32(); var xOffset = reader.ReadInt32(); var yOffset = reader.ReadInt32(); var xAdvance = reader.ReadInt32(); var textureRegion = new Subtexture(textures[textureIndex], x, y, width, height); regions[r] = new BitmapFontRegion(textureRegion, character, xOffset, yOffset, xAdvance); } return(new BitmapFont(regions, lineHeight)); }
public void draw( Subtexture subtexture, Vector2 position, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth ) { checkBegin(); pushSprite( subtexture, position.X, position.Y, scale.X, scale.Y, color, origin, rotation, layerDepth, (byte)(effects & (SpriteEffects)0x03), 0, 0, 0, 0 ); }
public Entity createProjectiles(Vector2 positon, Vector2 velocity) { //create Entity to house the projectile and its logic var entity = createEntity("projectile"); entity.position = positon; entity.addComponent(new ProjectileMover()); entity.addComponent(new ProjectileController(velocity)); //add a collider so we can detect intersections //var box = new BoxCollider(new Rectangle(0, 0, 64, 32)); var collider = entity.addComponent(new BoxCollider(64, 16)); Flags.setFlagExclusive(ref collider.collidesWithLayers, 0); //What layer to collide with (Map) Flags.setFlagExclusive(ref collider.physicsLayer, 2); //Setting the collision layer for the entity //load up a Texture that contains a fireball animation and setup the animation for ready to use var texture = content.Load <Texture2D>(Paths.Misc.shock); var subtexture = Subtexture.subtexturesFromAtlas(texture, 64, 64); var spriteAnimation = new SpriteAnimation(subtexture) { loop = true, fps = 15 }; //add the Sprites to the entity and play the animation creating it var sprite = entity.addComponent(new Sprite <int>(subtexture[0])); //render after our player who is on renderLayer 0, the default sprite.addAnimation(0, spriteAnimation); sprite.play(0); return(entity); }
private Sprite BuildSpaceshipDriveSprite() { var spaceshipDriveTexture = contentManager.Load <Texture2D>(SpaceshipDriveTextureName); var spaceshipDriveSubtextures = Subtexture.subtexturesFromAtlas(spaceshipDriveTexture, 32, 32); var fireAnimationSprite = new Sprite <int>(spaceshipDriveSubtextures[0]); fireAnimationSprite.SetRenderLayer(500); fireAnimationSprite.SetLocalOffset(new Vector2(1f, 28f)); var animation = new SpriteAnimation(new List <Subtexture>() { spaceshipDriveSubtextures[0], spaceshipDriveSubtextures[1], spaceshipDriveSubtextures[2], spaceshipDriveSubtextures[3] }); animation.setOrigin(new Vector2(0, 0)); fireAnimationSprite.AddAnimation(0, animation); fireAnimationSprite.Play(0); return(fireAnimationSprite); }
public NineSliceSprite(Subtexture subtexture) : base(subtexture) { generateRects(subtexture.sourceRect, _sourceRects); width = subtexture.sourceRect.Width + 150; height = subtexture.sourceRect.Height + 50; }
private void setupAnimations() { var texture = scene.content.Load <Texture2D>("sprites/kit_from_firefox"); var subtextures = Subtexture.subtexturesFromAtlas(texture, 56, 80); animation = addComponent(new Sprite <Animations>(subtextures[0])); animation.transform.scale = new Vector2(0.5f, 0.5f); animation.color = Color.LightSlateGray; animation.addAnimation(Animations.Waiting, new SpriteAnimation(new List <Subtexture>() { subtextures[0], subtextures[1], subtextures[2] }).setFps(3)); animation.addAnimation(Animations.Walking, new SpriteAnimation(new List <Subtexture>() { subtextures[4], subtextures[5], subtextures[6] }).setFps(7)); animation.addAnimation(Animations.FellOver, new SpriteAnimation(new List <Subtexture>() { subtextures[0] })); }
public Conmunication(string textResource, string content) { var tx = Core.scene.content.Load <Texture2D>(textResource); this.texture = new Subtexture(tx); this.content = content; }
private void createSubtextures() { _subtextures = new Subtexture[9]; var ert = new Rectangle(0, 0, (int)EdgeSize.X, (int)EdgeSize.Y); var brt = new Rectangle(0, 0, (int)BorderSize.X, (int)BorderSize.Y); var t = _texture; var st = new Subtexture[9]; // First row var y = 0; _subtextures[0] = new Subtexture(t, ert); _subtextures[1] = new Subtexture(t, new Rectangle(ert.Width, y, brt.Width, brt.Height)); _subtextures[2] = new Subtexture(t, new Rectangle(ert.Width + brt.Width, y, ert.Width, ert.Height)); // Second row y += ert.Height; _subtextures[3] = new Subtexture(t, new Rectangle(0, y, brt.Width, brt.Height)); _subtextures[4] = new Subtexture(t, new Rectangle(ert.Width, y, brt.Width, brt.Height)); _subtextures[5] = new Subtexture(t, new Rectangle(ert.Width + brt.Height, y, brt.Width, brt.Height)); // Third row y += brt.Width; _subtextures[6] = new Subtexture(t, new Rectangle(0, y, brt.Width, brt.Height)); _subtextures[7] = new Subtexture(t, new Rectangle(ert.Width, y, brt.Width, brt.Height)); _subtextures[8] = new Subtexture(t, new Rectangle(ert.Width + brt.Height, y, brt.Width, brt.Height)); }
public override void onAddedToScene() { // Cargamos las hojas de sprites var texture = scene.content.Load <Texture2D>(Content.Sprite.coin); var subtextures = Subtexture.subtexturesFromAtlas(texture, sizeFrame, sizeFrame); animation = this.addComponent(new Sprite <AnimationType>(subtextures[0])); this.position = new Vector2(this.position.X + sizeFrame / 2, this.position.Y); // Establecemos las animaciones //--------------------------------------------------------------------------------- // Idle (rotate) animation.addAnimation(AnimationType.Idle, new SpriteAnimation(new List <Subtexture>() { subtextures[0], subtextures[1], subtextures[2], subtextures[3], subtextures[4], subtextures[5], subtextures[6] })); this.Animation = AnimationType.Idle; }
public override void initialize() { base.initialize(); // required renderer stuff clearColor = new Color(40, 204, 223); var renderer = addRenderer(new DefaultRenderer()); var backgroundTexture = content.Load <Texture2D>("img/house"); var bgEntity = addEntity(new Entity()); bgEntity.addComponent(new Sprite(backgroundTexture)); bgEntity.position = new Vector2(NezGame.designWidth / 2f, NezGame.designHeight / 2f); var carTexture = content.Load <Texture2D>("img/car"); var carSubtextures = Subtexture.subtexturesFromAtlas(carTexture, 56, 24); var car = new Car(carSubtextures, true); addEntity(car); var tileTexture = content.Load <Texture2D>("img/basic-prototyping"); var tiles = Subtexture.subtexturesFromAtlas(tileTexture, 16, 16); carFinale = content.Load <SoundEffect>("audio/CAR_FINALE"); ballSound = content.Load <SoundEffect>("audio/Ball"); CreateKid(tiles); }
public override void initialize() { base.initialize(); //Load in and add the closedDoor sprite Subtexture closedTex = new Subtexture(scene.content.Load <Texture2D>("Sprites/closedDoor")); closedDoor.setSubtexture(closedTex); closedDoor.setEnabled(true); addComponent(closedDoor); closedDoor.setRenderLayer(0); closedDoor.transform.position = new Vector2(obj.x + obj.width / 2, (obj.y + obj.height / 2) + 1); getCollider <BoxCollider>().setLocalOffset(new Vector2(0, 0));// add one here ^ because it is up by for some reason otherwise (moves this down by one in game pixel) //Load in and add the openDoor sprite //Starts off disabled because the door starts closed Subtexture openTex = new Subtexture(scene.content.Load <Texture2D>("Sprites/openDoor")); openDoor.setSubtexture(openTex); openDoor.setEnabled(false); addComponent(openDoor); openDoor.setRenderLayer(0); openDoor.transform.position = new Vector2(obj.x + obj.width / 2, (obj.y + obj.height / 2) + 1); getCollider <BoxCollider>().setLocalOffset(new Vector2(0, 0));// add one here ^ because it is up by for some reason otherwise (moves this down by one in game pixel) }
public override void onAddedToEntity() { FramesToAttack = new int[] { 7 }; CurrentFrame = 0; HitboxOffset = new Vector2(7, -14); HitboxOffsetFlip = new Vector2(-26, -14); var texture = entity.scene.contentManager.Load <Texture2D>(_type); var runTexture = entity.scene.contentManager.Load <Texture2D>(_type + "run"); var hurtTexture = entity.scene.contentManager.Load <Texture2D>(_type + "hurt"); var attackTexture = entity.scene.contentManager.Load <Texture2D>(_type + "attack"); var subtextures = Subtexture.subtexturesFromAtlas(texture, 16, 16); var hurtSubtextures = Subtexture.subtexturesFromAtlas(hurtTexture, 20, 20); var attackSubtextures = Subtexture.subtexturesFromAtlas(attackTexture, 50, 50); var runSubtextureTexture = Subtexture.subtexturesFromAtlas(runTexture, 50, 50); _mover = entity.addComponent(new Mover()); _animation = entity.addComponent(new Sprite <Animations>(subtextures[0])); _animation.setRenderLayer(0); _animation.addAnimation(Animations.Idle, new SpriteAnimation(new List <Subtexture>() { subtextures[0], subtextures[0], subtextures[1], subtextures[1], subtextures[2], subtextures[2], subtextures[3], subtextures[3] })); _animation.addAnimation(Animations.Stun, new SpriteAnimation(new List <Subtexture>() { hurtSubtextures[0], hurtSubtextures[0] })); _animation.addAnimation(Animations.Attack, new SpriteAnimation(new List <Subtexture>() { attackSubtextures[0], attackSubtextures[1], attackSubtextures[2], attackSubtextures[3], attackSubtextures[4], attackSubtextures[5], attackSubtextures[6], attackSubtextures[7], attackSubtextures[8], attackSubtextures[9] })); _animation.addAnimation(Animations.Run, new SpriteAnimation(new List <Subtexture>() { runSubtextureTexture[0], runSubtextureTexture[1], runSubtextureTexture[2], runSubtextureTexture[3] })); }
internal static int SelectedBlock; // Выбранный блок, соответствует точке 1 #endregion Fields #region Methods // Метод применения текстуры кнопокам из файлов public static void ApplyButtonImage(string widgetName, string normalSubtexture, string clickedSubtexture) { if (File.Exists(normalSubtexture)) { using (FileStream fs = new FileStream(normalSubtexture, FileMode.Open, FileAccess.Read, FileShare.Read)) { Subtexture subtexture = new Subtexture(Texture2D.Load(fs), Vector2.Zero, Vector2.One); ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>(widgetName, true).NormalSubtexture = subtexture; fs.Close(); } } else Log.Warning("Subtexture " + normalSubtexture + " not found!"); if (File.Exists(clickedSubtexture)) { using (FileStream fs = new FileStream(clickedSubtexture, FileMode.Open, FileAccess.Read, FileShare.Read)) { Subtexture subtexture = new Subtexture(Texture2D.Load(fs), Vector2.Zero, Vector2.One); ScreensManager.CurrentScreen.ScreenWidget.FindWidget<BitmapButtonWidget>(widgetName, true).ClickedSubtexture = subtexture; fs.Close(); } } else Log.Warning("Subtexture " + clickedSubtexture + " not found!"); }