represents a single element in a texture atlas consisting of a texture and the source rectangle for the frame
Example #1
0
 public TextureAtlas( string[] regionNames, Subtexture[] subtextures, Dictionary<string,Point> spriteAnimationDetails, int animationFPS = 15 )
 {
     this.regionNames = regionNames;
     this.subtextures = subtextures;
     _spriteAnimationDetails = spriteAnimationDetails;
     _animationFPS = animationFPS;
 }
Example #2
0
		public BitmapFontRegion( Subtexture textureRegion, char character, int xOffset, int yOffset, int xAdvance )
		{
			this.subtexture = textureRegion;
			this.character = character;
			this.xOffset = xOffset;
			this.yOffset = yOffset;
			this.xAdvance = xAdvance;
		}
Example #3
0
		public TiledSprite( Subtexture subtexture ) : base( subtexture )
		{
			_sourceRect = subtexture.sourceRect;
			material = new Material
			{
				samplerState = Core.defaultWrappedSamplerState
			};
		}
Example #4
0
		public void unload()
		{
			if( pixelTexture != null )
				pixelTexture.texture2D.Dispose();
			pixelTexture = null;

			batcher.Dispose();
			batcher = null;
		}
Example #5
0
		public Graphics( BitmapFont font )
		{
			batcher = new Batcher( Core.graphicsDevice );
			bitmapFont = font;

			// the bottom/right pixel is white on the default font so we'll use that for the pixelTexture
			var fontTex = bitmapFont.defaultCharacterRegion.subtexture.texture2D;
			pixelTexture = new Subtexture( fontTex, fontTex.Width - 1, fontTex.Height - 1, 1, 1 );
		}
Example #6
0
		public Subtexture createRegion( string name, int x, int y, int width, int height, float pivotX = 0.5f, float pivotY = 0.5f )
		{
			Assert.isFalse( _subtextureMap.ContainsKey( name ), "Region {0} already exists in the texture atlas", name );

			var region = new Subtexture( texture, new Rectangle( x, y, width, height ), new Vector2( pivotX * width, pivotY * height ) );
			var index = subtextures.Count;
			subtextures.Add( region );
			_subtextureMap.Add( name, index );

			return region;
		}
Example #7
0
        public Arrow()
        {
            id = GameItemId.arrow;
            var texture = Core.content.Load <Texture2D>("Images/Players/Allplayer");

            itemIcon     = new Nez.Textures.Subtexture(texture, new Rectangle(306, 2630 - 1191 - 16, 5, 16));
            name         = "弓箭";
            describetion = "使用弓时所需要的东西";
            properties   = new string[] { "无" };
            saleMoney    = 1;
        }
Example #8
0
        public Subtexture createRegion( string name, int x, int y, int width, int height )
        {
            if( _subtextureMap.ContainsKey( name ) )
                throw new InvalidOperationException( "Region {0} already exists in the texture atlas" );

            var region = new Subtexture( texture, x, y, width, height );
            var index = subtextures.Count;
            subtextures.Add( region );
            _subtextureMap.Add( name, index );

            return region;
        }
Example #9
0
        public TiledSprite( Subtexture subtexture )
            : base(subtexture)
        {
            material = new Material();

            // choose the best fit wrap type based on the defaultSamplerState
            if( Core.defaultSamplerState.Filter == TextureFilter.Point )
                material.samplerState = SamplerState.PointWrap;
            else
                material.samplerState = SamplerState.LinearWrap;
            _sourceRect = subtexture.sourceRect;
        }
Example #10
0
			public void spawn( Vector2 position, Subtexture subtexture, float fadeDuration, float fadeDelay, Color initialColor, Color targetColor )
			{
				this.position = position;
				_subtexture = subtexture;

				_initialColor = initialColor;
				_elapsedTime = 0f;

				_fadeDuration = fadeDuration;
				_fadeDelay = fadeDelay;
				_initialColor = initialColor;
				_targetColor = targetColor;
			}
Example #11
0
 public NormalBowWeapon()
 {
     itemIcon     = new Nez.Textures.Subtexture(Core.content.Load <Texture2D>("Images/ItemsIcon/W_Bow03"));
     name         = "普通的弓";
     maxDamage    = 7;
     minDamage    = 4;
     describetion = "一把普通的弓";
     saleMoney    = 100;
     properties   = new string[] { "伤害 + 7" };
     id           = GameItemId.normalArrow;
     this.equit   = Equit;
     this.tackOff = TackOff;
 }
Example #12
0
        public override void onAddedToScene()
        {
            base.onAddedToScene();
            var texture    = Core.content.Load <Texture2D>("Images/Players/Allplayer");
            var subtexture = new Nez.Textures.Subtexture(texture, new Rectangle(306, 2630 - 1191 - 16, 5, 16));

            addComponent(new Sprite(subtexture)).setLayerDepth(LayerDepthExt.caluelateLayerDepth(this.position.Y));

            addComponent <FSRigidBody>()
            .setBodyType(BodyType.Dynamic);

            var shape = addComponent <SceneObjectTriggerComponent>();

            shape.setRadius(7).setIsSensor(true);
            shape.setCollisionCategories(CollisionSetting.ItemsCategory);
            shape.setCollidesWith(CollisionSetting.playerCategory);
            shape.onAdded = () =>
            {
                shape.GetFixture().onCollision += Body_onCollision;
            };
        }
Example #13
0
 public SpriteAnimationFrame( Subtexture subtexture, Vector2 origin )
 {
     this.subtexture = subtexture;
     this.origin = origin;
 }
Example #14
0
 public TextureAtlas( string[] regionNames, Subtexture[] subtextures )
     : this(regionNames, subtextures, null)
 {
 }
Example #15
0
		public SubtextureDrawable( Subtexture subtexture )
		{
			this.subtexture = subtexture;
		}
Example #16
0
		public ScrollingSprite( Subtexture subtexture ) : base( subtexture )
		{}
Example #17
0
		public Image( Subtexture subtexture, Scaling scaling = Scaling.Stretch, int align = AlignInternal.center ) : this( new SubtextureDrawable( subtexture ), scaling, align )
		{
		}
Example #18
0
		/// <summary>
		/// adds a frame to this animation
		/// </summary>
		/// <param name="subtexture">Subtexture.</param>
		public SpriteAnimation addFrame( Subtexture subtexture )
		{
			frames.Add( subtexture );
			return this;
		}
Example #19
0
		public FSCompoundPolygonBody( Subtexture subtexture ) : base( subtexture )
		{ }
Example #20
0
 public SpriteAnimationFrame( Subtexture subtexture )
     : this(subtexture, subtexture.center)
 {
 }
Example #21
0
 public Sprite( Subtexture subtexture )
 {
     this.subtexture = subtexture;
     originNormalized = new Vector2( 0.5f, 0.5f );
 }
Example #22
0
		public Sprite( Subtexture subtexture )
		{
			_subtexture = subtexture;
			_origin = subtexture.center;
		}
Example #23
0
		public FSPolygonBody( Subtexture subtexture, List<Vector2> verts ) : base( subtexture )
		{			
			_verts = new Vertices( verts );
		}
Example #24
0
		public NinePatchDrawable( Subtexture subtexture, int left, int right, int top, int bottom ) : this( new NinePatchSubtexture( subtexture.texture2D, subtexture.sourceRect, left, right, top, bottom ) )
		{}
Example #25
0
		public FSCircleBody( Subtexture subtexture ) : base( subtexture )
		{ }
Example #26
0
		public SpriteAnimation( Subtexture frame )
		{
			addFrame( frame );
		}
Example #27
0
 public NinePatchSubtexture(Subtexture subtexture, int left, int right, int top, int bottom)
     : this(subtexture, subtexture.sourceRect, left, right, top, bottom)
 {
 }
Example #28
0
		public FSBoxBody( Subtexture subtexture ) : base( subtexture, PolygonTools.createRectangle( subtexture.sourceRect.Width / 2, subtexture.sourceRect.Height / 2 ) )
		{ }
Example #29
0
 public NineSliceSprite( Subtexture subtexture, int top, int bottom, int left, int right )
     : this(new NinePatchSubtexture( subtexture, top, bottom, left, right ))
 {
 }
Example #30
0
		public TiledDrawable( Subtexture subtexture ) : base( subtexture )
		{
		}
Example #31
0
		/// <summary>
		/// sets the Subtexture and updates the origin of the Sprite to match Subtexture.origin. If for whatever reason you need
		/// an origin different from the Subtexture either clone it or set the origin AFTER setting the Subtexture here.
		/// </summary>
		/// <returns>The subtexture.</returns>
		/// <param name="subtexture">Subtexture.</param>
		public Sprite setSubtexture( Subtexture subtexture )
		{
			_subtexture = subtexture;

			if( _subtexture != null )
				_origin = subtexture.origin;
			return this;
		}
Example #32
0
		protected FSRenderableBody( Subtexture subtexture )
		{
			_subtexture = subtexture;
		}
Example #33
0
		public NinePatchSubtexture( Subtexture subtexture, int left, int right, int top, int bottom ) : this( subtexture, subtexture.sourceRect, left, right, top, bottom )
		{}
		public void setTileTextureRegion( int tileId, Rectangle sourceRect )
		{
			_regions[tileId] = new Subtexture( texture, sourceRect );
		}