本文整理汇总了C#中Sprite类的典型用法代码示例。如果您正苦于以下问题:C# Sprite类的具体用法?C# Sprite怎么用?C# Sprite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sprite类属于命名空间,在下文中一共展示了Sprite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例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");
}
示例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;
}
}
示例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);
}
}
示例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();
}
示例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];
}
}
示例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();
}
}
示例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);
}
示例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;
}
示例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;
}
示例11: Button
public Button(Sprite sprite)
: base()
{
m_buttonSprite = sprite;
m_transform = m_buttonSprite.Transform;
m_aabb = new AABB(m_transform, m_buttonSprite.Dimensions);
}
示例12: Shield
public Shield(string pname, float pweight, float pdefense, Sprite psprite)
{
itemName = pname;
weight = pweight;
sprite = psprite;
defense = pdefense;
}
示例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);
}
示例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;
}
示例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;
}