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 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); }
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); }
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 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); }
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], })); }
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 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); }
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] })); }
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 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] })); }
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 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] })); }
public static Entity CreatePlayer(Scene scene, int playerId, TiledObject spawnObj, TiledTileLayer collisionLayer) { var player = scene.addEntity(new Entity($"player{spawnObj.name}")).setPosition(spawnObj.position); var origin = new Vector2(8, 8); var texture = scene.content.Load <Texture2D>("samurai"); var subtextures = Subtexture.subtexturesFromAtlas(texture, 32, 16, 0, 4); subtextures[0].origin = new Vector2(8, 8); subtextures[1].origin = new Vector2(8, 8); subtextures[2].origin = new Vector2(8, 8); subtextures[3].origin = new Vector2(8, 8); var sprite = player.addComponent(new Sprite <PlayerAnims>(subtextures[2])); sprite.addAnimation(PlayerAnims.Normal, new SpriteAnimation(subtextures[0])); var attackAnim = new SpriteAnimation(subtextures.GetRange(0, 4)); attackAnim.setLoop(false); sprite.addAnimation(PlayerAnims.Attack, attackAnim); sprite.play(PlayerAnims.Normal); player.addComponent(new Input(playerId)); var box = player.addComponent(new BoxColliderFlip(-3, -6, 10, 14)); box.name = "movebox"; box.physicsLayer = 1 << 2; box.collidesWithLayers = 1 << 0; player.addComponent(new TiledMapMover(collisionLayer)); var controller = player.addComponent <PlayerController>(); player.addComponent(new ScreenWrapComponent(new Vector2(256, 144), new Vector2(16, 16), sprite)); var hitbox = player.addComponent(new BoxColliderFlip(8, -8, 16, 16)); hitbox.name = "hitbox"; hitbox.physicsLayer = 1 << 3; hitbox.collidesWithLayers = 1 << 4; hitbox.active = false; hitbox.isTrigger = true; var hurtBox = player.addComponent(new BoxColliderFlip(-3, -6, 10, 14)); hurtBox.name = "hurtbox"; hurtBox.physicsLayer = 1 << 4; hurtBox.collidesWithLayers = 1 << 3; player.addComponent(new AttackController()); player.addComponent <EnemyHit>(); sprite.onAnimationCompletedEvent += (anim) => { if (anim == PlayerAnims.Attack) { hitbox.active = false; sprite.play(PlayerAnims.Normal); } }; return(player); }
public override void onAddedToScene() { base.onAddedToScene(); var texture = scene.content.Load <Texture2D>("Images/Enemys/Slime"); var subtexture = Subtexture.subtexturesFromAtlas(texture, 32, 32); initAnimation(subtexture); initActorProperty(); initCollision(); addComponent(new SlimeBehaviorTree(this)); }
protected List <Subtexture> SetUpTextureAtlas(string charaterSpritePath) { // load up the TextureAtlas that we generated with the Pipeline tool specifying individual files var textureAtlas = scene.content.Load <Texture2D>(charaterSpritePath); // fetch a Subtexture from the atlas. A Subtexture consists of the Texture2D and the rect on the Texture2D this particular image ended up var subtexture = Subtexture.subtexturesFromAtlas(textureAtlas, width, height); return(subtexture); }
/// <summary> /// Initialise the AnimatedEntity. /// This MUST be called if you are not assigning the SubTextures and Sprite manually. /// </summary> protected void Initialise(Texture2D spritesheet, int width, int height = -1, int staticFrame = 0) { // C# is stupid. if (height == -1) { height = spritesheet.Height; } SubTextures = Subtexture.subtexturesFromAtlas(spritesheet, width, height); Sprite = new Sprite <TKey>(SubTextures[staticFrame]); addComponent(Sprite); }
public override void onAddedToEntity() { // load up our character texture atlas. we have different characters in 1 - 6.png for variety var characterPng = Nez.Random.range(1, 7); var texture = entity.scene.content.Load <Texture2D>("NinjaAdventure/characters/" + characterPng); var subtextures = Subtexture.subtexturesFromAtlas(texture, 16, 16); _mover = entity.addComponent(new Mover()); _animation = entity.addComponent(new Sprite <Animations>(subtextures[0])); // add a shadow that will only be rendered when our player is behind the detailss layer of the tilemap (renderLayer -1). The shadow // must be in a renderLayer ABOVE the details layer to be visible. var shadow = entity.addComponent(new SpriteMime(_animation)); shadow.color = new Color(10, 10, 10, 80); shadow.material = Material.stencilRead(); shadow.renderLayer = -2; // ABOVE our tiledmap layer so it is visible // extract the animations from the atlas _animation.addAnimation(Animations.WalkDown, new SpriteAnimation(new List <Subtexture>() { subtextures[0], subtextures[4], subtextures[8], subtextures[12] })); _animation.addAnimation(Animations.WalkUp, new SpriteAnimation(new List <Subtexture>() { subtextures[1], subtextures[5], subtextures[9], subtextures[13] })); _animation.addAnimation(Animations.WalkLeft, new SpriteAnimation(new List <Subtexture>() { subtextures[2], subtextures[6], subtextures[10], subtextures[14] })); _animation.addAnimation(Animations.WalkRight, new SpriteAnimation(new List <Subtexture>() { subtextures[3], subtextures[7], subtextures[11], subtextures[15] })); setupInput(); }
public void loadContent() { //Implement later musicAttack_1 = entity.scene.content.Load <Texture2D>("Temp/MusicSprite1"); //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] })); //Attack Idle animation _animations.addAnimation(Animations.ATTACK_IDLE, new SpriteAnimation(new List <Subtexture>() { subtextures[16], subtextures[17], subtextures[18] })); //Attack Run animation _animations.addAnimation(Animations.ATTACK_RUN, new SpriteAnimation(new List <Subtexture>() { subtextures[24], subtextures[25], subtextures[26] })); /* * _animations.addAnimation(Animations.IDLE, atlas.getSpriteAnimation("Idle")); * _animations.addAnimation(Animations.RUN, atlas.getSpriteAnimation("Run")); * _animations.addAnimation(Animations.ATTACK_IDLE, atlas.getSpriteAnimation("Attack_Idle")); * _animations.addAnimation(Animations.ATTACK_RUN, atlas.getSpriteAnimation("Attack_Run")); */ Debug.log("Content loaded"); }
public override void initialize() { clearColor = Color.Black; addRenderer(new DefaultRenderer()); setDesignResolution(1280 / 2, 720 / 2 + 8, Scene.SceneResolutionPolicy.ShowAllPixelPerfect); // load a TiledMap and move it back so is drawn before other entities var tiledEntity = createEntity("tiled-map"); var tiledmap = contentManager.Load <TiledMap>("bin/MacOSX/Tilemap/destructable-map"); tiledEntity.addComponent(new TiledMapComponent(tiledmap, "main")); var objects = tiledmap.getObjectGroup("objects"); var spawn = objects.objectWithName("spawn"); var ball = objects.objectWithName("ball"); var atlas = contentManager.Load <Texture2D>("bin/MacOSX/Tilemap/desert-palace-tiles2x"); 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 Nez.Shadows.PointLight(100) { collidesWithLayers = 1 << 0, color = Color.MonoGameOrange * 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; playerEntity.colliders.add(new BoxCollider()); playerEntity.colliders.mainCollider.physicsLayer = 1 << 2; playerEntity.colliders.mainCollider.collidesWithLayers = 1 << 0; var ballSubtexture = atlasParts[atlasParts.Count - 26 + 8]; var ballEntity = createEntity("ball"); ballEntity.transform.position = new Vector2(ball.x, ball.y); ballEntity.addComponent(new Sprite(ballSubtexture)); ballEntity.addComponent(new ArcadeRigidbody()); ballEntity.colliders.add(new CircleCollider()); ballEntity.colliders.mainCollider.physicsLayer = 1 << 1; ballEntity.colliders.mainCollider.collidesWithLayers = 1 << 0; }
public override void onAddedToEntity() { var texture = entity.scene.contentManager.Load <Texture2D>("drop"); var subtextures = Subtexture.subtexturesFromAtlas(texture, 2, 2); _mover = entity.addComponent(new Mover()); _animation = entity.addComponent(new Sprite <Animations>(subtextures[0])); _animation.addAnimation(Animations.Idle, new SpriteAnimation(new List <Subtexture>() { subtextures[0] })); }
public static Scene sceneOne(bool showAll = true) { var scene = Scene.createWithDefaultRenderer(Color.Black); scene.letterboxColor = Color.MonoGameOrange; if (showAll) { scene.setDesignResolution(256, 144, Scene.SceneResolutionPolicy.ShowAllPixelPerfect); } else { scene.setDesignResolution(256, 144, Scene.SceneResolutionPolicy.NoBorderPixelPerfect); } // load a TiledMap and move it back so is drawn before other entities var tiledEntity = scene.createEntity("tiled-map-entity"); var tiledmap = scene.contentManager.Load <TiledMap>("bin/MacOSX/Tilemap/tilemap"); tiledEntity.addComponent(new TiledMapComponent(tiledmap, "collision")); var tiledEntityTwo = scene.createEntity("tiled-map-entity-two"); tiledEntityTwo.transform.position = new Vector2(256, 0); tiledEntityTwo.addComponent(new TiledMapComponent(tiledmap, "collision")); // create a sprite animation from an atlas var plumeTexture = scene.contentManager.Load <Texture2D>("Images/plume"); var subtextures = Subtexture.subtexturesFromAtlas(plumeTexture, 16, 16); var spriteAnimation = new SpriteAnimation(subtextures) { loop = true, fps = 10 }; var sprite = new Sprite <int>(subtextures[0]); sprite.renderLayer = -1; sprite.addAnimation(0, spriteAnimation); sprite.play(0); var spriteEntity = scene.createEntity("sprite-dude"); spriteEntity.transform.position = new Vector2(40, 40); spriteEntity.addComponent(sprite); scene.finalRenderDelegate = new PixelMosaicRenderDelegate(); return(scene); }
public override void onAddedToEntity() { // load up our character texture atlas. we have different characters in 1 - 6.png for variety var texture = entity.scene.content.Load <Texture2D>("postac/postac"); var subtextures = Subtexture.subtexturesFromAtlas(texture, 20, 31); var a = 5; _mover = entity.addComponent(new Mover()); _animation = entity.addComponent(new Sprite <Animations>(subtextures[0])); var shadow = entity.addComponent(new SpriteMime(_animation)); shadow.color = new Color(10, 10, 10, 80); shadow.material = Material.stencilRead(); shadow.renderLayer = -2; // ABOVE our tiledmap layer so it is visible // extract the animations from the atlas _animation.addAnimation(Animations.WalkDown, new SpriteAnimation(new List <Subtexture>() { subtextures[0], subtextures[1], subtextures[2], })); _animation.addAnimation(Animations.WalkUp, new SpriteAnimation(new List <Subtexture>() { subtextures[3], subtextures[4], subtextures[5], })); _animation.addAnimation(Animations.WalkLeft, new SpriteAnimation(new List <Subtexture>() { subtextures[6], subtextures[7], subtextures[8], })); _animation.addAnimation(Animations.WalkRight, new SpriteAnimation(new List <Subtexture>() { subtextures[9], subtextures[10], subtextures[11], })); setupInput(); }
public override void onAddedToScene() { base.onAddedToScene(); tag = (int)Tags.Idol; var texture = scene.content.Load <Texture2D>("sprites/buddhas"); var subtextures = Subtexture.subtexturesFromAtlas(texture, 32, 35); sprite = addComponent(new Sprite(subtextures[0])); sprite.renderLayer = 1; controller = addComponent <IdolController>(); }
public override void onAddedToScene() { base.onAddedToScene(); var texture = scene.content.Load <Texture2D>(Content.Player.player); var subtextures = Subtexture.subtexturesFromAtlas(texture, 128, 128); var idleAnimation = new SpriteAnimation(new List <Subtexture>() { subtextures[0], subtextures[1], subtextures[2], subtextures[3], subtextures[4], subtextures[5], subtextures[6], subtextures[7] }); var runAnimation = new SpriteAnimation(new List <Subtexture>() { subtextures[8], subtextures[9], subtextures[10], subtextures[11], subtextures[12], subtextures[13], subtextures[14], subtextures[15] }); _sprite = addComponent(new Sprite <Animation>(subtextures[0])); _sprite.addAnimation(Animation.Idle, idleAnimation); _sprite.addAnimation(Animation.Run, runAnimation); _jumpInput = new VirtualButton(); _jumpInput.nodes.Add(new Nez.VirtualButton.KeyboardKey(Keys.Space)); _jumpInput.nodes.Add(new Nez.VirtualButton.KeyboardKey(Keys.W)); _jumpInput.nodes.Add(new Nez.VirtualButton.GamePadButton(0, Buttons.A)); _moveInput = new VirtualAxis(); _moveInput.nodes.Add(new Nez.VirtualAxis.GamePadDpadLeftRight()); _moveInput.nodes.Add(new Nez.VirtualAxis.GamePadLeftStickX()); _moveInput.nodes.Add(new Nez.VirtualAxis.KeyboardKeys(VirtualInput.OverlapBehavior.TakeNewer, Keys.Left, Keys.Right)); _sprite.play(Animation.Idle); }
private void initializeEquitTable() { equitTable = new Table(); windowFrame = Core.content.Load <Texture2D>("UI/window_frame_grey"); buttonFrame = Core.content.Load <Texture2D>("UI/frame_grey"); var back = new SubtextureDrawable(new Nez.Textures.Subtexture(windowFrame)); back.setPadding(0, 620, 0, 540); equitTable.setBackground(back); equitTable.setSize(540, 620); allContain.add(equitTable).top().left().pad(25); var helmet = createItembutton(player.helmet); var armor = createItembutton(player.armor); var shoes = createItembutton(player.shoes); var necklace = createItembutton(player.necklace); var wristbands = createItembutton(player.wristbands); var ring = createItembutton(player.ring); var weapon = createItembutton(player.weapon); var shield = createItembutton(player.shield); int addition = 80; var playerTexture = Core.content.Load <Texture2D>("Images/Players/player"); var subtexture = Subtexture.subtexturesFromAtlas(playerTexture, 24, 32); equitTable.addElement(new Image(subtexture[0])).setPosition(198, 80).setScale(6f); equitTable.addElement(helmet).setPosition(30, 30).setSize(64, 64); equitTable.addElement(armor).setPosition(30, 30 + addition).setSize(64, 64); equitTable.addElement(shoes).setPosition(30, 30 + addition * 2).setSize(64, 64); equitTable.addElement(necklace).setPosition(446, 30).setSize(64, 64); equitTable.addElement(wristbands).setPosition(446, 30 + addition).setSize(64, 64); equitTable.addElement(ring).setPosition(446, 30 + addition * 2).setSize(64, 64); equitTable.addElement(weapon).setPosition(150, 320).setSize(64, 64); equitTable.addElement(shield).setPosition(326, 320).setSize(64, 64); InitPropertiesTable(); }
public override void onAddedToScene() { var texture = scene.content.Load <Texture2D>("Images/ItemsObjects/treasureBox_small"); var subtexture = Subtexture.subtexturesFromAtlas(texture, 14, 14); animation = addComponent(new Sprite <TreasureBoxStates>(subtexture[0])); animation.setRenderLayer(GameLayerSetting.actorMoverLayer) .setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y)); animation.addAnimation(TreasureBoxStates.Close, new SpriteAnimation(subtexture[0])); animation.addAnimation(TreasureBoxStates.Open, new SpriteAnimation(subtexture[1])); if (hasOpened) { animation.currentAnimation = TreasureBoxStates.Open; } else { animation.currentAnimation = TreasureBoxStates.Close; } animation.play(animation.currentAnimation); var rigidBody = addComponent <FSRigidBody>() .setBodyType(FarseerPhysics.Dynamics.BodyType.Dynamic); trigger = addComponent <SceneObjectTriggerComponent>(); trigger.setRadius(10) .setIsSensor(true); trigger.setCollisionCategories(CollisionSetting.ItemsCategory); trigger.setCollidesWith(CollisionSetting.playerCategory); trigger.onAdded += onAddedMethod; var eButtontexture = scene.content.Load <Texture2D>("Images/ItemsObjects/EButton"); eButtonSprite = addComponent(new Sprite(eButtontexture)); eButtonSprite.setLocalOffset(new Vector2(-14, -14 - eButtonSprite.height)); eButtonSprite.enabled = false; var openTexture = scene.content.Load <Texture2D>("Images/ItemsObjects/openFont"); openSprite = addComponent(new Sprite(openTexture)); openSprite.setLocalOffset(new Vector2(-14 + eButtonSprite.width * 2, -14 - eButtonSprite.height)); openSprite.enabled = false; }
public static void Initialise() { Texture2D infrastrucureSpriteAtlas = Core.content.Load <Texture2D>("hospitalceo/tiles"); INFRASTRUCTURE_SPRITE_ALTAS = Subtexture.subtexturesFromAtlas(infrastrucureSpriteAtlas, 100, 100); Nez.Console.DebugConsole.instance.log("Amount of infrastructure textures loaded: " + INFRASTRUCTURE_SPRITE_ALTAS.Count); Texture2D characterSpriteAltas = Core.content.Load <Texture2D>("hospitalceo/characters"); CHARACTER_SPRITE_ATLAS = Subtexture.subtexturesFromAtlas(characterSpriteAltas, 70, 70); Nez.Console.DebugConsole.instance.log("Amount of character textures loaded: " + CHARACTER_SPRITE_ATLAS.Count); Texture2D objectSpriteAtlas = Core.content.Load <Texture2D>("hospitalceo/objects"); OBJECT_SPRITE_ATLAS = Subtexture.subtexturesFromAtlas(objectSpriteAtlas, 200, 100); Nez.Console.DebugConsole.instance.log("Amount of object textures loaded: " + OBJECT_SPRITE_ATLAS.Count); }
public override void onAddedToScene() { base.onAddedToScene(); this.setScale(2f); this.actorProperty = addComponent <ActorPropertyComponent>(); this.actorProperty.HP = this.actorProperty.MaxHP = 500; this.actorProperty.moveSpeed = 70; var texture = scene.content.Load <Texture2D>("Images/Enemys/Slime"); var subtexture = Subtexture.subtexturesFromAtlas(texture, 32, 32); initAnimation(subtexture); initCollision(); this.target = Core.getGlobalManager <GameActorManager>().player; addComponent(new BigSlimeSimpleStateMachine(this)); addComponent(new BigSlimeHPBar(this)).setRenderLayer(GameLayerSetting.playerUiLayer);; }
/// <summary> /// creates a projectile and sets it in motion /// </summary> /// <returns>The projectile.</returns> /// <param name="position">Position.</param> /// <param name="velocity">Velocity.</param> public Entity createProjectiles(Vector2 position, Vector2 velocity) { // create an Entity to house the projectile and its logic var entity = createEntity("projectile"); entity.transform.position = position; entity.addComponent(new ProjectileMover()); entity.addComponent(new FireballProjectileController(velocity)); // add a collider so we can detect intersections var collider = entity.colliders.add(new CircleCollider()); Flags.setFlagExclusive(ref collider.collidesWithLayers, 0); Flags.setFlagExclusive(ref collider.physicsLayer, 1); // load up a Texture that contains a fireball animation and setup the animation frames var texture = contentManager.Load <Texture2D>("NinjaAdventure/plume"); var subtextures = Subtexture.subtexturesFromAtlas(texture, 16, 16); var spriteAnimation = new SpriteAnimation(subtextures) { loop = true, fps = 10 }; // add the Sprite to the Entity and play the animation after creating it var sprite = entity.addComponent(new Sprite <int>(subtextures[0])); // render after (under) our player who is on renderLayer 0, the default sprite.renderLayer = 1; sprite.addAnimation(0, spriteAnimation); sprite.play(0); // clone the projectile and fire it off in the opposite direction var newEntity = entity.clone(entity.transform.position); newEntity.getComponent <FireballProjectileController>().velocity *= -1; addEntity(newEntity); return(entity); }