本文整理汇总了C#中Sprite.SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.SetPosition方法的具体用法?C# Sprite.SetPosition怎么用?C# Sprite.SetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.SetPosition方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Tile
protected Tile(TileState state, RectangleF rect)
{
_resourceManager = IoCManager.Resolve<IResourceManager>();
_lightManager = IoCManager.Resolve<ILightManager>();
tileState = state;
bounds = rect;
Sprite = _resourceManager.GetSprite("space_texture");
Sprite.SetPosition(Position.X, Position.Y);
}
示例2: BackGround
public BackGround(TextureManager _texturemanager, int level, Particle.Particles _p = null)
{
if (_p != null)
{
particles = _p;
allowrunParticles = true;
}
this.level = level;
renderer = Stage1State._renderer;
this.texturemanager = _texturemanager;
Texture texture = _texturemanager.Get("shade1");
background = new Sprite();
background.Texture = texture;
background.SetPosition(0, 225);
background.SetHeight(450);
background.SetWidth(385+10);
tree = new List<Tree>();
//添加一开始就有的树
for (int i = 0; i < 3; i++)
{
backgroundimage = new BackGroundImage(_texturemanager, renderer, "stg1bg", new Rectangle(0.01f, 0.01f, 0.48f, 0.48f), 385+10, 450);
SpeedY = 0.05f;
backgroundimage.SetPosition(0, 225);
Tree tree1 = new Tree(texturemanager, renderer, "stg1bg", false, 200, 200);
tree1.setTop(400);
tree1.setPosition(16 + 30 * (float)random.NextDouble() - 15, i*200 + 60 * (float)random.NextDouble() - 30);
tree.Add(tree1);
tree1 = new Tree(texturemanager, renderer, "stg1bg", true, 200, 200);
tree1.setTop(400);
tree1.setPosition(-100 + 30 * (float)random.NextDouble() - 15, i * 200 + 100 * (float)random.NextDouble() - 50);
tree.Add(tree1);
tree1 = new Tree(texturemanager, renderer, "stg1bg", true, 200, 200);
tree1.setTop(400);
tree1.setPosition(160 + 30 * (float)random.NextDouble() - 15, i * 200 + 60 * (float)random.NextDouble() - 30);
tree.Add(tree1);
}
}
示例3: AddExplosion
// Add an explosion into the list (will remove self once complete)
public void AddExplosion(Vector2 Position)
{
// Allocate and register the new sprite, starting with the explosion
// Note: slight randomization to add effect
Sprite Explosion = new Sprite("Textures/ExplosionSprite" + UnityEngine.Random.Range(0, 2)); // [0, 1]
Explosion.SetPosition(Position);
Explosion.SetAnimation(Vector2.zero, new Vector2(20, 20), 7, 0.06f + UnityEngine.Random.Range(-0.01f, 0.05f));
Explosion.SetGeometrySize(Explosion.GetSpriteSize() * (0.6f + UnityEngine.Random.Range(-0.2f, 0.2f)));
Explosion.SetRotationCenter(Explosion.GetGeometrySize() / UnityEngine.Random.Range (1.0f, 2.0f));
Explosion.SetRotation(UnityEngine.Random.Range(0.0f, 2.0f * Mathf.PI));
Explosion.SetDepth(Globals.ExplosionDepth);
// Register to renderer and list
Globals.WorldView.SManager.AddSprite(Explosion);
Explosions.Add(Explosion);
// Add explosion audio
int Index = UnityEngine.Random.Range(1, 4); // [1, 4)
Globals.WorldView.AManager.PlayAudio(Position, "Explosion" + Index);
}
示例4: BackGroundImage3D
public BackGroundImage3D(TextureManager _t, Renderer _renderer, string TextureName, float width = 385, float height = 450)
{
texturemanager = _t;
renderer = _renderer;
this.width = width; this.height = height;
Sprite sp;
sp = new Sprite();
sp.Texture = texturemanager.Get(TextureName);
sp.SetWidth(width);
sp.SetHeight(height);
sp.SetPosition(X, Y);
Sprites.Add(sp);
sp = new Sprite();
sp.Texture = texturemanager.Get(TextureName);
sp.SetWidth(width);
sp.SetHeight(height);
sp.SetPosition(X, Y);
Sprites.Add(sp);
}
示例5: BackGroundImage
public BackGroundImage(TextureManager _t ,Renderer _renderer, string TextureName ,
Rectangle UVs, float width = 385, float height = 450)
{
texturemanager = _t;
renderer = _renderer;
current_rect = new Rectangle(0.1f, 0, 0.8f, 0.8f);
this.UVs = UVs;
this.width = width; this.height = height;
map_up = new Sprite();
map_up.Texture = texturemanager.Get(TextureName);
map_up.SetWidth(width);
map_up.SetHeight(height);
map_up.SetPosition(X, Y);
map_up.SetUVs(new Point(current_rect.X , current_rect.Y),
new Point(current_rect.X+current_rect.Width, current_rect.Y+ current_rect.Height));
map_down = new Sprite();
map_down.Texture = texturemanager.Get(TextureName);
map_down.SetWidth(width);
map_down.SetHeight(height);
map_down.SetPosition(X, Y);
map_down.SetUVs(new Point(current_rect.X, current_rect.Y),
new Point(current_rect.X + current_rect.Width, current_rect.Y + current_rect.Height));
}
示例6: CreateSprite
//Does exactly what it says on the tin.
public static Sprite CreateSprite(string texture, int x, int y, float scale)
{
Sprite sprite = new Sprite(textures[texture], texture);
sprite.scale = scale;
sprite.SetPosition(x, y);
sprite.name = texture;
gObjects.Add(sprite);
return sprite;
}
示例7: CreateMultiSprite
//Creates a sprite with multiple images. Can be used for animation, different states, etc.
public static Sprite CreateMultiSprite(string[] texture, int x, int y, float scale)
{
List<Texture2D> texes = new List<Texture2D>();
for (int i = 0; i < texture.Length; i++)
{
texes.Add(textures[texture[i]]);
}
Sprite sprite = new Sprite(texes, texture);
sprite.scale = scale;
sprite.SetPosition(x, y);
sprite.name = texture[0];
gObjects.Add(sprite);
return sprite;
}
示例8: Main
public static void Main(string[] args)
{
Initialize();
Console.Out.WriteLine("Left-click on graph to zoom in.");
Console.Out.WriteLine("Right-click on graph to toggle between Mandelbrot/Julia graphs.");
Console.Out.WriteLine("Press the SPACE key to create a new palette.");
Console.Out.WriteLine("Press the ENTER key to smooth the graph.");
Console.Out.WriteLine("Press the cursor keys to scroll the graph up/down/left/right.");
Console.Out.WriteLine("Press the ESC key to close the application.");
Console.Out.WriteLine();
Console.Out.WriteLine("Press ENTER to start.");
Console.In.ReadLine();
Clear();
PointerTexture = AddSpriteTexture(GetResourceBitmap("Pointer.png"), System.Drawing.Color.FromArgb(0, 0, 255), true);
ZTexture = AddSpriteTexture(GetResourceBitmap("Z.png"), System.Drawing.Color.FromArgb(0, 0, 255), true);
Point P = GetMousePointer();
Pointer = CreateSprite(P.X, P.Y, PointerTexture);
double re0 = -0.5;
double im0 = 0;
double dr = 5;
double cre0 = 0;
double cim0 = 0;
Color[] Palette = CreatePalette(1024, 16);
OnKeyDown += (sender, e) =>
{
switch (e.Key)
{
case Key.Escape:
Terminated.Set();
break;
case Key.C:
if (e.Control)
Terminated.Set();
break;
case Key.Space:
NewPalette.Set();
break;
case Key.Enter:
CalcSmooth.Set();
break;
case Key.Left:
if (!Calculating)
{
re0 -= dr * 0.25;
NewFractal.Set();
}
break;
case Key.Right:
if (!Calculating)
{
re0 += dr * 0.25;
NewFractal.Set();
}
break;
case Key.Up:
if (!Calculating)
{
im0 -= dr * 0.25;
NewFractal.Set();
}
break;
case Key.Down:
if (!Calculating)
{
im0 += dr * 0.25;
NewFractal.Set();
}
break;
}
};
OnMouseMove += (sender, e) =>
{
P = e.Position;
Pointer.SetPosition(P);
int DX = P.X - RasterWidth / 2;
int DY = P.Y - RasterHeight / 2;
Pointer.Angle = 90 + 22.5 + System.Math.Atan2(DY, DX) * 180 / System.Math.PI;
};
CalcMandelbrot(re0, im0, dr, Palette);
OnMouseDown += (sender, e) =>
{
if (!Calculating)
{
//.........这里部分代码省略.........
示例9: initiazeSprits
void initiazeSprits()
{
initPosition();
Sprits = new Dictionary<int, DoubleSprites>();
Texture tex = _texturemanager.Get("Title_01");
for (int i = 0; i < 9; i++)
{
Sprite spr1 = new Sprite();
Sprite spr2 = new Sprite();
spr1.Texture = tex;
spr2.Texture = tex;
if (i == _START_)
{
spr1.SetUVs(new Point(0, 0), new Point(0.3125f, 0.0625f));
spr2.SetUVs(new Point(0.3125f, 0), new Point(0.625f, 0.0625f));
spr1.SetWidth(160); spr1.SetHeight(32);
spr2.SetWidth(160); spr2.SetHeight(32);
}
else if (i == _RESULT__)
{
changeUnit(ref spr1, 0, 16, 22, 20, unit_for512);
changeUnit(ref spr2, 22, 16, 44, 20, unit_for512);
spr1.SetWidth(22*8); spr1.SetHeight(32);
spr2.SetWidth(22*8); spr2.SetHeight(32);
}
else if (i == _MUSIC_)
{
changeUnit(ref spr1, 0, 20, 22, 24, unit_for512);
changeUnit(ref spr2, 22, 20, 44, 24, unit_for512);
spr1.SetWidth(22 * 8); spr1.SetHeight(32);
spr2.SetWidth(22 * 8); spr2.SetHeight(32);
}
else if (i == _REPLY_)
{
changeUnit(ref spr1, 0, 12, 12, 16, unit_for512);
changeUnit(ref spr2, 12, 12, 24, 16, unit_for512);
spr1.SetWidth(12 * 8); spr1.SetHeight(32);
spr2.SetWidth(12 * 8); spr2.SetHeight(32);
}
else if (i == _OPTION_)
{
changeUnit(ref spr1, 0, 28, 14, 32, unit_for512);
changeUnit(ref spr2, 14, 28, 28, 32, unit_for512);
spr1.SetWidth(14 * 8); spr1.SetHeight(32);
spr2.SetWidth(14 * 8); spr2.SetHeight(32);
}
else if (i == _QUIT_)
{
changeUnit(ref spr1, 0, 32, 10, 36, unit_for512);
changeUnit(ref spr2, 10, 32, 20, 36, unit_for512);
spr1.SetWidth(10 * 8); spr1.SetHeight(32);
spr2.SetWidth(10 * 8); spr2.SetHeight(32);
}
spr1.SetPosition(Positions[i].X, Positions[i].Y);
spr2.SetPosition(Positions[i].X, Positions[i].Y);
Sprits.Add(i, new DoubleSprites(spr1, spr2));
}
}
示例10: PlayerOne
public PlayerOne(TextureManager _t , Renderer renderer)
{
this.renderer = renderer;
Width = 32;
Height = 48;
position = new Vector2D(0, 50);
//Texture texture = _t.Get("Player00");
//sprite = new Sprite();
//sprite.Texture = texture;
//sprite.SetWidth(Width);
//sprite.SetHeight(Height);
//sprite.SetPosition(position.X, position.Y);
//multiSprite = new MultiSprite(sprite);
//RecTangleF[] rects = new RecTangleF[8];
//for (int i = 0; i < 8;i++ )
// rects[i] = new RecTangleF(0 + i * 4 * per_256, 0, 4 * per_256 + i * 4 * per_256, 6 * per_256);
//multiSprite.RegeditState(0, rects); //将此rectangleF注册到0号state
//multiSprite.State = 0; //将状态切换为0号state
Texture texture = _t.Get("Player2");
sprite = new Sprite();
sprite.Texture = texture;
sprite.SetWidth(Width);
sprite.SetHeight(Height);
sprite.SetPosition(position.X, position.Y);
multiSprite = new MultiSprite(sprite);
RecTangleF[] rects = new RecTangleF[4];
for (int i = 0; i < 4; i++)
rects[i] = new RecTangleF(0 + i * 4 * per_256, 0, 4 * per_256 + i * 4 * per_256, 6 * per_256);
multiSprite.RegeditState(0, rects); //将此rectangleF注册到0号state
rects = new RecTangleF[3];
for (int i = 0; i < 3; i++)
rects[i] = new RecTangleF( i * 4 * per_256, 6 * per_256,
4 * per_256 + i * 4 * per_256, 12 * per_256);
multiSprite.RegeditState(1, rects); //将此rectangleF注册到1号state (过渡移动)
rects = new RecTangleF[4];
for (int i = 0; i < 4; i++)
rects[i] = new RecTangleF(12*per_256 + i * 4 * per_256, 6*per_256,
12*per_256+ 4 * per_256 + i * 4 * per_256, 12 * per_256);
multiSprite.RegeditState(2, rects); //将此rectangleF注册到2号state (移动)
rects = new RecTangleF[3];
for (int i = 0; i < 3; i++)
rects[i] = new RecTangleF(4 * per_256 + i * 4 * per_256, 6 * per_256,
i * 4 * per_256, 12 * per_256);
multiSprite.RegeditState(3, rects); //将此rectangleF注册到3号state (过渡移动,右)
rects = new RecTangleF[4];
for (int i = 0; i < 4; i++)
rects[i] = new RecTangleF(12 * per_256 + 4 * per_256 + i * 4 * per_256, 6 * per_256,
12 * per_256 + i * 4 * per_256 , 12 * per_256);
multiSprite.RegeditState(4, rects); //将此rectangleF注册到4号state (移动)
multiSprite.RegeditCollection(1, 2); //将1号动画连接到2号动画上
multiSprite.RegeditCollection(3, 4); //将3号动画连接到4号动画上
multiSprite.State = 1; //将状态切换为1号state
}
示例11: SetSpriteCenter
public void SetSpriteCenter(Sprite sprite, Vector2D center)
{
sprite.SetPosition(center.X - (GetActiveDirectionalSprite().AABB.Width/2),
center.Y - (GetActiveDirectionalSprite().AABB.Height/2));
}
示例12: UpdateSpriteStates
public void UpdateSpriteStates(CoronaObject obj, float worldScale, Point offsetPoint)
{
if (this.currentProject != null)
{
if (obj.isEntity == true)
{
for (int i = 0; i < obj.Entity.CoronaObjects.Count; i++)
{
this.UpdateSpriteStates(obj.Entity.CoronaObjects[i], worldScale,offsetPoint);
}
}
else
{
if (obj.DisplayObject != null)
{
Sprite sprite = null;
if (obj.DisplayObject.Type.Equals("IMAGE"))
{
sprite = obj.DisplayObject.GorgonSprite;
if (sprite == null)
{
this.UpdateSpriteContent(obj, worldScale, offsetPoint);
return;
}
if (obj.DisplayObject.ImageFillColor == Color.Empty)
obj.DisplayObject.ImageFillColor = Color.White;
sprite.SetPosition((float)obj.DisplayObject.SurfaceRect.X + sprite.Axis.X + offsetPoint.X,
(float)obj.DisplayObject.SurfaceRect.Y + sprite.Axis.Y + offsetPoint.Y);
sprite.Rotation = obj.DisplayObject.Rotation;
sprite.Color = Color.FromArgb((int)(obj.DisplayObject.Alpha * 255.0f), obj.DisplayObject.ImageFillColor);
float imgScaleX = (float)obj.DisplayObject.SurfaceRect.Width / (float)sprite.Image.Width;
float imgScaleY = (float)obj.DisplayObject.SurfaceRect.Height / (float)sprite.Image.Height;
float finalXScale = worldScale * imgScaleX;
float finalYScale = worldScale * imgScaleY;
sprite.SetScale(finalXScale, finalYScale);
sprite.SetAxis((float)sprite.Image.Width / 2, (float)sprite.Image.Height / 2);
sprite.Rotation = obj.DisplayObject.Rotation;
}
else if (obj.DisplayObject.Type.Equals("SPRITE"))
{
CoronaSpriteSet spriteSetParent = obj.DisplayObject.SpriteSet;
sprite = obj.DisplayObject.GorgonSprite;
if (sprite == null)
{
this.UpdateSpriteContent(obj, worldScale, offsetPoint);
return;
}
if (obj.DisplayObject.CurrentSequence == "DEFAULT")
{
if (obj.DisplayObject.SpriteSet.Frames.Count > 0)
{
//Charger le sprite avec la current frame
SpriteFrame spriteFrame = spriteSetParent.Frames[obj.DisplayObject.CurrentFrame];
float factor = obj.DisplayObject.SpriteSet.Frames[obj.DisplayObject.CurrentFrame].SpriteSheetParent.FramesFactor;
if (factor <= 0)
factor = 1;
int width = Convert.ToInt32((float)sprite.Image.Width / factor);
int height = Convert.ToInt32((float)sprite.Image.Height / factor);
obj.DisplayObject.SurfaceRect = new Rectangle(obj.DisplayObject.SurfaceRect.Location, new Size(width, height));
}
}
else
{
CoronaSpriteSetSequence sequence = obj.DisplayObject.getSequenceByName(obj.DisplayObject.CurrentSequence);
if (sequence != null)
{
int convertedCurrentFrame = obj.DisplayObject.CurrentFrame + sequence.FrameDepart - 1;
if (obj.DisplayObject.SpriteSet.Frames.Count > 0 && obj.DisplayObject.SpriteSet.Frames.Count > convertedCurrentFrame)
{
//Charger le sprite avec la current frame
SpriteFrame spriteFrame = spriteSetParent.Frames[convertedCurrentFrame];
float factor = obj.DisplayObject.SpriteSet.Frames[convertedCurrentFrame].SpriteSheetParent.FramesFactor;
if (factor <= 0)
factor = 1;
int width = Convert.ToInt32((float)sprite.Image.Width / factor);
int height = Convert.ToInt32((float)sprite.Image.Height / factor);
obj.DisplayObject.SurfaceRect = new Rectangle(obj.DisplayObject.SurfaceRect.Location, new Size(width, height));
}
else
{
obj.DisplayObject.CurrentFrame = sequence.FrameCount - 1;
this.UpdateSpriteContent(obj, worldScale,offsetPoint);
}
//.........这里部分代码省略.........
示例13: AddGlow
// Add glow ontop of what is being fired
public void AddGlow(Vector2 Position)
{
// Sprite info
Vector2 GlowPos = ProjectileInfo.GetKey_Vector2("Glow", "Pos");
Vector2 GlowSize = ProjectileInfo.GetKey_Vector2("Glow", "Size");
// Allocate and register the new sprite
// Note: slight randomization to add effect
Sprite Explosion = new Sprite("Textures/Projectiles");
Explosion.SetAnimation(GlowPos, GlowSize, 1, 1.0f);
// Set in-world properties
Explosion.SetPosition(Position);
Explosion.SetGeometrySize(Explosion.GetSpriteSize() * (0.6f + UnityEngine.Random.Range(-0.2f, 0.2f)));
Explosion.SetRotationCenter(Explosion.GetGeometrySize() / 2.0f);
Explosion.SetRotation(UnityEngine.Random.Range(0.0f, 2.0f * Mathf.PI));
Explosion.SetDepth(Globals.ExplosionDepth);
// Register to renderer and list
Globals.WorldView.SManager.AddSprite(Explosion);
Glow.Add(Explosion);
}