public static uint[] GetTextureData(SpriteSheet spriteSheet, Rectangle spriteSourceRect) { int dataLength = spriteSourceRect.Width * spriteSourceRect.Height; uint[] pixelData = new uint[dataLength]; spriteSheet.Texture.GetData<uint>(0, spriteSourceRect, pixelData, 0, dataLength); return pixelData; }
public override void Restore(Vector2 position, SpriteSheet spriteSheet, ObjectDataBase objectData) { base.Restore(position, spriteSheet, objectData); buttonCircle = new Circle(position + new Vector2(400 + spriteSheet.SourceRectangle(0).Width / 2, 280 + spriteSheet.SourceRectangle(0).Height / 2), 75); color = Color.Red; }
public NewSprite(string sheetName, List<int> sequence, float frequency, bool cyclic) { Spritesheet = Persistence.Persistence.GetAsset<SpriteSheet>(sheetName); Sequence = sequence; Frequency = frequency; Cyclic = cyclic; ElapsedTime = 0; CurrentFrame = 0; Images = new List<Image>(); for (int i = 0; i < Spritesheet.ImagesCount; i++) Images.Add(new Image(Spritesheet.GetImageName(i), Vector3.Zero, sheetName)); Active = true; TextureSize = Images[0].TextureSize; Center = TextureSize / 2f; Position = position; Origin = Center; Size = Vector2.One; Rotation = 0f; Blend = BlendType.Alpha; Color = Color.White; VisualPriority = 0; Id = Visuals.NextHashCode; CurrentFrameChanged = true; AttributeChanged = true; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); spriteSheet = Content.Load<SpriteSheet>("assets"); //TODO: Add files to these directories. spriteFont = Content.Load<SpriteFont>("hudFont"); // TODO: use this.Content to load your game content here }
public SpriteSheet Copy() { SpriteSheet spriteSheet = new SpriteSheet(); spriteSheet.texture = new Texture2D(this.texture.GraphicsDevice, this.texture.Width, this.texture.Height); spriteSheet.spriteRectangles = this.spriteRectangles; spriteSheet.spriteNames = this.spriteNames; spriteSheet.framesPerDir = this.framesPerDir; spriteSheet.frameTime = this.frameTime; return spriteSheet; }
public override void Restore(Vector2 position, SpriteSheet spriteSheet, ObjectDataBase objectData) { const string CYPHERS_PATH = "Sprites/UI/HUD/Digit/cyphers"; //this.cyphersTexture = Resources.Content.Load<Texture2D>(CYPHERS_PATH + id); cypherWidth = spriteSheet.SourceRectangle(0).Width; cypherHeight = spriteSheet.SourceRectangle(0).Height; cypherRect = new Rectangle(0, 0, cypherWidth, cypherHeight); base.Restore(position, spriteSheet, objectData); }
public AnimatedGameComponent(EasyTopDownGame game, string sheetName) : base(game) { base.imageName = sheetName; this.Category = sheetName; LayerDepth = LayerDepths.Middle; this.SecondsPerFrame = .2; spriteSheet = game.Content.Load<SpriteSheet>(sheetName); Initialize(); InitializePhysics(); Scale = 1; }
public static PhysicsFrame GetVerticesForTexture(SpriteSheet spriteSheet, int index) { Rectangle spriteSourceRect = spriteSheet.SourceRectangle(index); uint[] textureData = GetTextureData(spriteSheet, spriteSourceRect); return GetVerticesForTextureData(textureData, spriteSourceRect.Width); }
public AnimatedSprite(SpriteSheet spriteSheet) { this.spriteSheet = spriteSheet; this.frameTime = spriteSheet.FrameTime; }
public AnimationTable(AnimationTable table) { this.animations = new SortedDictionary<string, Animation>(); this.spriteSheet = table.spriteSheet; this.current =table.current; foreach(KeyValuePair<String, Animation> kvp in table.animations) { this.animations.Add(kvp.Key, new Animation(kvp.Value.Indices, kvp.Value.AnimationInterval)); } }
public AnimationTable(SpriteSheet spriteSheet, SortedDictionary<string, Animation> animations, string current) { this.spriteSheet = spriteSheet; this.animations = animations; this.current = current; }
private void Rotate(int flips, SpriteSheet input, ref SpriteSheet output) { for (int i = 0; i < frames; i++) { input.Texture.GetData(0, input.SourceRectangle(i), textureOriginal, 0, textureOriginal.Length); for (int j = 0; j < flips; j++) { for (int x = 0; x < size; x++) { for (int y = 0; y < size; y++) { textureFlipped[(x*size + size - y - 1)*PIXEL_SIZE + 0] = textureOriginal[(x + y*size)*PIXEL_SIZE + 0]; textureFlipped[(x*size + size - y - 1)*PIXEL_SIZE + 1] = textureOriginal[(x + y*size)*PIXEL_SIZE + 1]; textureFlipped[(x*size + size - y - 1)*PIXEL_SIZE + 2] = textureOriginal[(x + y*size)*PIXEL_SIZE + 2]; textureFlipped[(x*size + size - y - 1)*PIXEL_SIZE + 3] = textureOriginal[(x + y*size)*PIXEL_SIZE + 3]; } } } output.Texture.SetData(0, output.SourceRectangle(i), textureFlipped, 0, textureFlipped.Length); } }
public void Initialize() { const string MIDDLEBLOW_PATH = "Sprites/Blow/Middle/Sprites"; const string CENTERBLOW_PATH = "Sprites/Blow/Center/Sprites"; const string OUTERBLOW_PATH = "Sprites/Blow/Outer/Sprites"; blowMiddle = new SpriteSheet[2]; blowOuter = new SpriteSheet[4]; blowCenter = GameResources.Content.Load<SpriteSheet>(CENTERBLOW_PATH); blowMiddle[0] = GameResources.Content.Load<SpriteSheet>(MIDDLEBLOW_PATH); blowMiddle[1] = blowMiddle[0].Copy(); blowOuter[0] = GameResources.Content.Load<SpriteSheet>(OUTERBLOW_PATH); for (int i = 1; i < 4; i++) { blowOuter[i] = blowOuter[0].Copy(); } size = blowCenter.SourceRectangle(0).Width; textureOriginal = new byte[size * size * PIXEL_SIZE]; textureFlipped = new byte[size * size * PIXEL_SIZE]; Rotate(2, blowMiddle[0], ref blowMiddle[1] ); Rotate(1, blowOuter[0], ref blowOuter[1]); Rotate(1, blowOuter[1], ref blowOuter[2]); Rotate(1, blowOuter[2], ref blowOuter[3]); }
public override void Restore(Vector2 tilePosition, SpriteSheet spriteSheet, ObjectDataBase enemyData) { isCreated = true; isDead = false; lastFrameReached = false; destinationReached = true; this.tilePosition = tilePosition; currentDestination = tilePosition; this.enemyData = enemyData as EnemyData; shadowTexture = Board.Instance.EffectsFactory.GetTexture(this.enemyData.ShadowId); setAction(EnemyData.Behavior.DoNothing); base.Restore(tilePosition * Board.TILE_SIZE, spriteSheet, enemyData); random = new Random(); }
public virtual void Restore(Vector2 position, SpriteSheet spriteSheet, ObjectDataBase objectData) { this.basePosition = position; this.frameTime = spriteSheet.FrameTime; this.spriteSheet = spriteSheet; frames = spriteSheet.FramesPerDir; currentFrame = 0; this.inUse = true; this.startupGameObject(); animatedObjects.Add(this); }
public AnimationTable(SpriteSheet spriteSheet) { this.spriteSheet = spriteSheet; this.animations = new SortedDictionary<string, Animation>(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // TODO: use this.Content to load your game content here sprites = Content.Load<SpriteSheet>("PlayerSprites"); Camera.Current.MaxX = 30000; Camera.Current.MaxY = 20000; Camera.Current.Zoom = targetZoom; Camera.Current.StartTracking(player); characterFont = Content.Load<SpriteFont>("Courier"); grassTile = Content.Load<Texture2D>("grass"); fireballTexture = Content.Load<Texture2D>("fireball"); mouseCursor = Content.Load<Texture2D>("arrow"); projectile = Content.Load<Texture2D>("projectile"); player.spriteRect = new Rectangle(0, 0, 16, 16); player.spritebase = "player"; CF.Initialize(Content.Load<Texture2D>("CF/cannonfodder1_sprites_grass2"), 16, 14); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { LineBatch.Init(GraphicsDevice); layers = new SortedList<String, Layer>(); camera = new Camera(Vector2.Zero); lines = new List<Line>(); randomNum = new Random(); collisionManager = new CollisionManager(); spriteBatch = new SpriteBatch(GraphicsDevice); controller = new Controller(); camera = new Camera(Vector2.Zero); spritesheet = Content.Load<SpriteSheet>("sheet"); spritesheet2 = Content.Load<SpriteSheet>("sheet2"); loadAnimationTables(); font = Content.Load<SpriteFont>("FromWhere"); loadLayers(); // TODO: use this.Content to load your game content here }