• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Sprite类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Sprite的典型用法代码示例。如果您正苦于以下问题:C# Sprite类的具体用法?C# Sprite怎么用?C# Sprite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Sprite类属于命名空间,在下文中一共展示了Sprite类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Pyramid

        public Pyramid(World world, Vector2 position, int count, float density)
        {
            Vertices rect = PolygonTools.CreateRectangle(0.5f, 0.5f);
            PolygonShape shape = new PolygonShape(rect, density);

            Vector2 rowStart = position;
            rowStart.Y -= 0.5f + count * 1.1f;

            Vector2 deltaRow = new Vector2(-0.625f, 1.1f);
            const float spacing = 1.25f;

            // Physics
            _boxes = new List<Body>();

            for (int i = 0; i < count; i++)
            {
                Vector2 pos = rowStart;

                for (int j = 0; j < i + 1; j++)
                {
                    Body body = BodyFactory.CreateBody(world);
                    body.BodyType = BodyType.Dynamic;
                    body.Position = pos;
                    body.CreateFixture(shape);
                    _boxes.Add(body);

                    pos.X += spacing;
                }
                rowStart += deltaRow;
            }

            //GFX
            _box = new Sprite(ContentWrapper.PolygonTexture(rect, "Square", ContentWrapper.Blue, ContentWrapper.Gold, ContentWrapper.Black, 1f));
        }
开发者ID:tinco,项目名称:Farseer-Physics,代码行数:34,代码来源:Pyramid.cs


示例2: GameScreen

        /// <summary>
        /// Create a new game screen. Should be done every time there is a new game.
        /// </summary>
        /// <param name="theScreenEvent"></param>
        /// <param name="contentManager"></param>
        public GameScreen(EventHandler theScreenEvent,ContentManager contentManager)
            : base(theScreenEvent)
        {
            bScoreWasAdded = false;

            this.contentManager = contentManager;
            dlDoubleJumpTimer = new DanLabel(1150, 20, 100, 50);

            //Init our intrepid hero
            csHero = new ControlledSprite();

            bg = new LayeredBackground();

            djeJumpEffect = new DoubleJumpEffect();

            altimeter = new Altimeter(); // Make a camera for the screen with an altimeter
            cCamera = new Camera(50, 100, 600, 520, altimeter);

            blocks = new List<Sprite>();
            Sprite sp = new Sprite();
            blocks.Add(sp);
            sp = new Sprite();
            blocks.Add(sp);
            sp = new Sprite();
            blocks.Add(sp);
            sp = new Sprite();
            blocks.Add(sp);
            sp = new Sprite();
            blocks.Add(sp);

            // REVIST Set up the Arcing Block Manager with the difficulty
            arcingBlockManager = new ArcingBlockManager(cCamera, blocks, contentManager, 500, 300, 150, "Sprites/block2");
        }
开发者ID:Shnagenburg,项目名称:ClimbGame,代码行数:38,代码来源:GameScreen.cs


示例3: Start

    // Use this for initialization
    void Start()
    {
        string personaje = PlayerPrefs.GetString("personaje");
        int contador = 0;
        foreach (var item in sprite)
        {
            if (item.name.ToUpper() == personaje.ToUpper())
            {
                character_sprite = item;
                if (SceneManager.GetActiveScene().name != "_Menu_principal")
                {
                    GetComponent<SphereCollider>().center = colliderMod[contador];
                }
            }
            contador++;
        }

        player = GameObject.FindGameObjectWithTag("Player");
        if (player != null)
        if (this != null)
        {
            SpriteRenderer player_transform = player.GetComponent<SpriteRenderer>();
            player_transform.sprite = character_sprite;
        }

        if (transform.name == "Image")
        {
            transform.GetComponent<Image>().sprite = character_sprite;
        }
    }
开发者ID:TapTapTapps,项目名称:WayPath,代码行数:31,代码来源:cambio_personaje.cs


示例4: Flip

	IEnumerator Flip(Sprite startImage, Sprite endImage, int cardIndex)

	{
		spriteRenderer.sprite = startImage;

		float time = 0f;
		while (time <= 2f) 
		{
			float scale = scaleCurve.Evaluate (time);
			time += Time.deltaTime / duration;

			Vector3 localScale = transform.localScale;
			localScale.x = scale;
			transform.localScale = localScale;

			if (time >= 0.5f) 
			{
				spriteRenderer.sprite = endImage;
			}

			yield return new WaitForFixedUpdate ();
		}

		if (cardIndex == -1) {
			model.ToggleFace (false);
		} 
		else 
		{
			model.cardIndex = cardIndex;
			model.ToggleFace (true);
		}
	}
开发者ID:SamShapiro,项目名称:UnityBlackjack,代码行数:32,代码来源:CardFlipper.cs


示例5: ShieldEffect

	public ShieldEffect (string n, int dur, int shield, Sprite icon = null)
		: base(n, dur, 1, icon)
	{
		maxShield = shield;
		shieldAmount = maxShield;
		description = "Damage Shield " + shieldAmount.ToString();
	}
开发者ID:JohnEz,项目名称:TileBasedEngine,代码行数:7,代码来源:ShieldEffect.cs


示例6: Vic

        public Vic(int newCycles, int newLines, int[][] newPipeline, int newCyclesPerSec, int hblankStart, int hblankEnd, int vblankStart, int vblankEnd)
        {
            {
                this.hblankStart = hblankStart;
                this.hblankEnd = hblankEnd;
                this.vblankStart = vblankStart;
                this.vblankEnd = vblankEnd;

                totalCycles = newCycles;
                totalLines = newLines;
                pipeline = newPipeline;
                cyclesPerSec = newCyclesPerSec;

                bufWidth = TimingBuilder_ScreenWidth(pipeline[0], hblankStart, hblankEnd);
                bufHeight = TimingBuilder_ScreenHeight(vblankStart, vblankEnd, newLines);

                buf = new int[bufWidth * bufHeight];
                bufLength = buf.Length;

                sprites = new Sprite[8];
                for (int i = 0; i < 8; i++)
                    sprites[i] = new Sprite();

                bufferC = new int[40];
                bufferG = new int[40];
            }
        }
开发者ID:cas1993per,项目名称:bizhawk,代码行数:27,代码来源:Vic.cs


示例7: FireShot

        public void FireShot(
            Vector2 location,
            Vector2 velocity,
            bool playerFired)
        {
            Sprite thisShot = new Sprite(
                location,
                Texture,
                InitialFrame,
                velocity);

            thisShot.Velocity *= shotSpeed;

            for (int x = 1; x < FrameCount; x++)
            {
                thisShot.AddFrame(new Rectangle(
                    InitialFrame.X + (InitialFrame.Width * x),
                    InitialFrame.Y,
                    InitialFrame.Width,
                    InitialFrame.Height));
            }
            thisShot.CollisionRadius = CollisionRadius;
            Shots.Add(thisShot);

            if (playerFired)
            {

                SoundManager.PlayPlayerShot();
            }
            else
            {

                SoundManager.PlayEnemyShot();
            }
        }
开发者ID:jacqmasc,项目名称:AsteroidAssault,代码行数:35,代码来源:ShotManager.cs


示例8: LoadAssets

 public override void LoadAssets()
 {
     mouthLeft = resourceFactory.Create(this, "MouthLeft-WeNeedThisTaste").GetComponent<Sprite>();
     mouthRight = resourceFactory.Create(this, "MouthRight-WeNeedThisTaste").GetComponent<Sprite>();
     mouthLeft.visible(false);
     mouthRight.visible(false);
 }
开发者ID:absurdhero,项目名称:tmotmo-full,代码行数:7,代码来源:SceneSeven.cs


示例9: LevelMenyState

        public LevelMenyState(Game1 game, Sprite spriteSheet)
            : base(game)
        {
            this.spriteSheet = spriteSheet;
            font = game.Content.Load<SpriteFont>("menyFont");

            knappar = new List<Clickable>();

            Random random = new Random();

            LevelMenyExitKnapp levelExit = new LevelMenyExitKnapp(game, spriteSheet, new Vector2(410, 550));
            levelExit.Initialize();

            Level1 lv1 = new Level1(game, spriteSheet, random);
            Level1Knapp level1knapp = new Level1Knapp(game, spriteSheet, new Vector2(200, 200), lv1);
            level1knapp.Initialize();
            lv1.AddLevelButton(level1knapp);

            Level2 lv2 = new Level2(game, spriteSheet, random);
            Level2Knapp level2knapp = new Level2Knapp(game, spriteSheet, new Vector2(300, 200), lv2);
            level2knapp.Initialize();
            lv2.AddLevelButton(level2knapp);

            Level3 lv3 = new Level3(game, spriteSheet, random);
            Level3Knapp level3knapp = new Level3Knapp(game, spriteSheet, new Vector2(400, 200), lv3);
            level3knapp.Initialize();
            lv3.AddLevelButton(level3knapp);

            Level4 lv4 = new Level4(game, spriteSheet, random);
            Level4Knapp level4knapp = new Level4Knapp(game, spriteSheet, new Vector2(500, 200), lv4);
            level4knapp.Initialize();
            lv4.AddLevelButton(level4knapp);

            Level5 lv5 = new Level5(game, spriteSheet, random);
            Level5Knapp level5knapp = new Level5Knapp(game, spriteSheet, new Vector2(600, 200), lv5);
            level5knapp.Initialize();
            lv5.AddLevelButton(level5knapp);

            Level6 lv6 = new Level6(game, spriteSheet, random);
            Level6Knapp level6knapp = new Level6Knapp(game, spriteSheet, new Vector2(700, 200), lv6);
            level6knapp.Initialize();
            lv6.AddLevelButton(level6knapp);

            LevelTest lvTest = new LevelTest(game, spriteSheet, random);
            TestLevelKnapp levelTestknapp = new TestLevelKnapp(game, spriteSheet, new Vector2(800, 600), lvTest);
            levelTestknapp.Initialize();
            lvTest.AddLevelButton(levelTestknapp);

            knappar.Add(level1knapp);
            knappar.Add(level2knapp);
            knappar.Add(level3knapp);
            knappar.Add(level4knapp);
            knappar.Add(level5knapp);
            knappar.Add(level6knapp);
            knappar.Add(levelTestknapp);

            knappar.Add(levelExit);

            textTimer = 0;
        }
开发者ID:Jakob37,项目名称:JDGAME,代码行数:60,代码来源:LevelMenyState.cs


示例10: KolizjaDlaOkregow

 public static bool KolizjaDlaOkregow(Sprite a, Sprite b)
 {
     float d = Odleglosc(a.pozycja, b.pozycja);
     if ((a.teksturaPodstawowa.Height * a.wielkoscObiektu.Y + +b.teksturaPodstawowa.Height * b.wielkoscObiektu.Y) / 2 > d)
         return true;
     return false;
 }
开发者ID:rtshadow,项目名称:miscs,代码行数:7,代码来源:Obliczarka.cs


示例11: Button

 public Button(Sprite sprite)
     : base()
 {
     m_buttonSprite = sprite;
     m_transform = m_buttonSprite.Transform;
     m_aabb = new AABB(m_transform, m_buttonSprite.Dimensions);
 }
开发者ID:TastyWithPasta,项目名称:ItsNotSafeOutside_XNA,代码行数:7,代码来源:Button.cs


示例12: Shield

 public Shield(string pname, float pweight, float pdefense, Sprite psprite)
 {
     itemName = pname;
     weight = pweight;
     sprite = psprite;
     defense = pdefense;
 }
开发者ID:watermelonade,项目名称:isometric-wars,代码行数:7,代码来源:Shield.cs


示例13: Pointed

	public void Pointed()
	{

		flag = Resources.Load<Sprite> (EarthManager.Instance.info_flag_path);

		Image tempImage=image.GetComponent<Image> ();

		tempImage.sprite = flag;

		//tempImage.sprite.texture
		//Text temp = GetComponent<Text> ();
		Text temp = title.GetComponent<Text> ();
		temp.text = EarthManager.Instance.title;

		temp = country.GetComponent<Text> ();
		temp.text = EarthManager.Instance.country;

		temp = area.GetComponent<Text> ();
		temp.text = EarthManager.Instance.area;

		temp = contents.GetComponent<Text> ();
		temp.text = EarthManager.Instance.contents;

		InformationCanvas.SetActive (true);
	}
开发者ID:koko11,项目名称:MatrixVR,代码行数:25,代码来源:InformationButton.cs


示例14: SpaceJunk

 public SpaceJunk(float x, float y, BitmapTexture2D texture, float scale)
 {
     Sprite = new Sprite(texture, scale);
     Sprite.UseCentreAsOrigin = true;
     Sprite.X = x;
     Sprite.Y = y;
 }
开发者ID:OrangeMonkey,项目名称:GOTYE,代码行数:7,代码来源:SpaceJunk.cs


示例15: Init

    public virtual void Init(Grid grid, int x, int y, float scale = 1, Sprite asset = null)
    {
        sfx = AudioManager.instance;

        container = transform.Find("Sprites");
        outline = transform.Find("Sprites/Outline").GetComponent<SpriteRenderer>();
        img = transform.Find("Sprites/Sprite").GetComponent<SpriteRenderer>();
        shadow = transform.Find("Sprites/Shadow").GetComponent<SpriteRenderer>();
        shadow.gameObject.SetActive(false);

        label = transform.Find("Label").GetComponent<TextMesh>();
        label.GetComponent<Renderer>().sortingLayerName = "Ui";
        label.gameObject.SetActive(Debug.isDebugBuild);

        this.grid = grid;
        this.x = x;
        this.y = y;
        this.asset = asset;

        this.walkable = true;

        transform.localPosition = new Vector3(x, y, 0);

        SetAsset(asset);
        SetImages(scale, Vector3.zero, 0);
        SetSortingOrder(0);

        visible = false;
        explored = false;
    }
开发者ID:snaptothegrid,项目名称:Tiler,代码行数:30,代码来源:Tile.cs


示例16: TgcDrawText

        public TgcDrawText(Device d3dDevice)
        {
            textSprite = new Sprite(d3dDevice);

            //Fuente default
            dxFont = new Microsoft.DirectX.Direct3D.Font(d3dDevice, VERDANA_10);
        }
开发者ID:aniPerezG,项目名称:barbalpha,代码行数:7,代码来源:TgcDrawText.cs


示例17: SpriteComponent

 public SpriteComponent(Sprite sprite, Texture2D texture)
 {
     Name = sprite.Id;
     Texture = texture;
     Origin = new Vector2(sprite.OriginX ?? sprite.W/2, sprite.OriginY ?? sprite.H/2);
     TextureRect = new Rectangle(sprite.X, sprite.Y, sprite.W, sprite.H);
 }
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:7,代码来源:SpriteComponent.cs


示例18: DamageComponent

        public DamageComponent(Sprite owner, int hitPoints, params string[] immuneTo)
        {
            // ...

            killActions.Add("stomp", s =>
                {
                    s.Graphics.State = "flattened"; // or whatever
                    s.AddTimer(seconds: 2.0f, action: sp => sp.Owner.RemoveSprite(sp));
                });

            killActions.Add("knock_off", s =>
            {
                s.Graphics.Orientation = GraphicsOrientation.UpsideDown;
                s.Velocity = GameServices.ISOStandardKnockOffVelocity;
                s.State = SpriteState.Inert;
            });

            killActions.Add("vaporize", s =>
            {
                s.Owner.RemoveSprite(s);
                s.Owner.CreateEffect("fireballPuff", s.Position);
                SoundManager.PlaySoundEffect("vaporize");
            });

            killActions.Add("default", s => s.Owner.RemoveSprite(s));
        }
开发者ID:smldev,项目名称:smlimitless,代码行数:26,代码来源:GoombaInteractionExample.cs


示例19: Instantiate

        //Method to Initiliaze
        public static void Instantiate()
        {
            //Initialize the buttongroup
            buttons = new ButtonGroup();

            background = new Sprite();
        }
开发者ID:bvanderdrift,项目名称:EpicGrip,代码行数:8,代码来源:MainMenu.cs


示例20: LoadContent

        public override void LoadContent()
        {
            base.LoadContent();

            World.Gravity = Vector2.Zero;

            _border = new Border(World, Lines, Framework.GraphicsDevice);
            for (int i = 0; i < 3; i++)
            {
                _breakableCookie[i] = Framework.Content.Load<BodyContainer>("Pipeline/FarseerBreakableBody")["Cookie"].CreateBreakable(World);
                _breakableCookie[i].Strength = 120f;
                _breakableCookie[i].MainBody.Position = new Vector2(-20.33f + 15f * i, -5.33f);
            }

            _breakableSprite = new List<Sprite>();
            List<Texture2D> textures = ContentWrapper.BreakableTextureFragments(_breakableCookie[0], "Cookie");
            for (int i = 0; i < _breakableCookie[0].Parts.Count; i++)
            {
                AABB bounds;
                Transform transform;
                _breakableCookie[0].Parts[i].Body.GetTransform(out transform);
                _breakableCookie[0].Parts[i].Shape.ComputeAABB(out bounds, ref transform, 0);
                Vector2 origin = ConvertUnits.ToDisplayUnits(_breakableCookie[0].Parts[i].Body.Position - bounds.LowerBound);
                _breakableSprite.Add(new Sprite(textures[i], origin));
            }
            _completeSprite = new Sprite(ContentWrapper.GetTexture("Cookie"), Vector2.Zero);
        }
开发者ID:RCGame,项目名称:FarseerPhysics,代码行数:27,代码来源:D18_BreakableBody.cs



注:本文中的Sprite类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SpriteBatch类代码示例发布时间:2022-05-24
下一篇:
C# SpreadsheetDocument类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap