本文整理汇总了C#中SFML.Graphics.Sprite类的典型用法代码示例。如果您正苦于以下问题:C# Sprite类的具体用法?C# Sprite怎么用?C# Sprite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sprite类属于SFML.Graphics命名空间,在下文中一共展示了Sprite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PauseState
public PauseState(StateStack stack, Context context)
: base(stack, context)
{
RenderWindow window = mContext.window;
mBackgroundSprite = new Sprite();
mPausedText = new Text();
mInstructionText = new Text();
mPausedText.Font = mContext.fonts.get(FontID.Main);
mPausedText.DisplayedString = "Game Paused";
mPausedText.CharacterSize = 70;
mPausedText.centerOrigin();
mPausedText.Position = new Vector2f(0, 0);
mInstructionText.Font = mContext.fonts.get(FontID.Main);
mInstructionText.DisplayedString = "(Press Backspace to return to main menu)";
mInstructionText.centerOrigin();
mInstructionText.Position = new Vector2f(0, 0);
backgroundShape = new RectangleShape();
backgroundShape.FillColor = new Color(0, 0, 0, 150);
backgroundShape.Position = window.GetView().Center;
backgroundShape.centerOrigin();
backgroundShape.Size = window.GetView().Size;
}
示例2: Draw
public void Draw()
{
SFML.Graphics.Sprite s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Button)[ID]);
s.Position = new Vector2f(X, Y);
_screen.Draw(s);
Text t = new Text();
t.Font = Program.Data.Font;
t.CharacterSize = 14;
CraftGUI g = (CraftGUI)Program.SM.States[1].GameGUI[10];
Items i = Program.Data.MyItems[Logic.KnownRecipeForThisCharacter(Logic.CurrentParty.MainParty.MyParty[0], g.CurClass).Count];
{
if (SlotID + 3 * g.CurPage < i.ItemRequired.Count)
{
s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Items)[Program.Data.MyItems[i.ItemRequired.ElementAt(SlotID + 3 * g.CurPage).Key].Sprite]);
s.Position = new Vector2f(X, Y);
_screen.Draw(s);
t.DisplayedString = Program.Data.MyItems[i.ItemRequired.ElementAt(SlotID + 3 * g.CurPage).Key].Name + ": " + i.ItemRequired.ElementAt(SlotID + 3 * g.CurPage).Value;
t.Position = new Vector2f(X + 38, Y + 8);
_screen.Draw(t);
}
}
}
示例3: BlueprintButton
public BlueprintButton(string c1, string c1N, string c2, string c2N, string res, string resname,
IResourceManager resourceManager)
{
_resourceManager = resourceManager;
Compo1 = c1;
Compo1Name = c1N;
Compo2 = c2;
Compo2Name = c2N;
Result = res;
ResultName = resname;
_icon = _resourceManager.GetSprite("blueprint");
Label = new TextSprite("blueprinttext", "", _resourceManager.GetFont("CALIBRI"))
{
Color = new SFML.Graphics.Color(248, 248, 255),
ShadowColor = new SFML.Graphics.Color(105, 105, 105),
ShadowOffset = new Vector2f(1, 1),
Shadowed = true
};
Update(0);
}
示例4: Player
public Player(string name, bool sandbox, Image image, uint width = 0, uint height = 0)
{
this.name = name;
this.alive = true;
this.health = 100;
this.sandbox = sandbox;
this.image = image;
this.sprite = new Sprite(image);
this.sprite.Position = new Vector2(10, 10);
if (width > 0 && height > 0)
{
this.sprite.Width = width;
this.sprite.Height = height;
}
else
{
this.sprite.Width = 32;
this.sprite.Height = 64;
}
this.inventoryList = new List<Item>();
}
示例5: DrawTop
public void DrawTop(RenderWindow rw)
{
SFML.Graphics.Sprite s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Resource)[Program.Data.GetResourceList()[ID].Sprite]);
s.Position = new Vector2f((X + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinX) * Program.Data.TileSizeX, (Y + Logic.CurrentParty.MainParty.MyParty[0].CurMap.MinY - 1) * Program.Data.TileSizeX);
s.TextureRect = new IntRect(0, 0, (int)(s.Texture.Size.X), (int)(s.Texture.Size.Y - Program.Data.GetResourceList()[ID].SizeY * 16));
rw.Draw(s);
}
示例6: Hud
public Hud(GameBase state)
{
_state = state;
_selected = new Sprite(Assets.LoadTexture("wep_selected.png")).Center();
_statusBack = new RectangleShape(new Vector2f(BarWidth + Padding * 2, BarHeight * 2 + Padding * 3));
_statusBack.Position = new Vector2f(Padding, Padding);
_statusBack.FillColor = new Color(0, 0, 0);
_statusBack.OutlineThickness = 2;
_statusBack.OutlineColor = new Color(38, 38, 38);
_health = new RectangleShape(new Vector2f(BarWidth, BarHeight));
_health.Position = _statusBack.Position + new Vector2f(Padding, Padding);
_health.FillColor = new Color(0, 120, 0);
_healthText = new Text("", Program.Font, (int)(BarHeight - Padding));
_healthText.Position = _health.Position + new Vector2f(BarWidth / 2, BarHeight / 2);
_healthText.Color = new Color(225, 225, 225);
_energy = new RectangleShape(new Vector2f(BarWidth, BarHeight));
_energy.Position = _health.Position + new Vector2f(0, BarHeight + Padding);
_energy.FillColor = new Color(30, 30, 180);
_energyText = new Text("", Program.Font, (int)(BarHeight - Padding));
_energyText.Position = _energy.Position + new Vector2f(BarWidth / 2, BarHeight / 2);
_energyText.Color = new Color(225, 225, 225);
}
示例7: GetSprite
public static Sprite GetSprite(string filename)
{
Sprite sprite = new Sprite(GetTexture(filename));
sprite.Texture.Smooth = true;
return sprite;
}
示例8: Deathmatch
public Deathmatch()
: base()
{
Projectiles = new List<Projectile>();
BackgroundImages = new List<Sprite>();
BackgroundImagesFar = new List<Sprite>();
BackgroundTracks = new List<Sprite>();
BackgroundGameObjects = new List<GameObject>();
Players = new List<Actor>();
Mailman = new ClientMailman(this);
shader = new RenderStates(new Shader(null, "Content/bgPrlx.frag"));
Image mapImg = new Image("Content/mapCol.png");
mapBytes = mapImg.Pixels;
mapSprite = new Sprite(new Texture(mapImg));
mapWidth = (int)mapImg.Size.X;
mapHeight = (int)mapImg.Size.Y;
player = new ClientPlayer(this);
player.Pos = new Vector2f(46, 62);
Players.Add(player);
trainSoundExterior = new SoundInstance(Content.GetSound("trainSpeed2.wav"), 1f, 0, 15, true);
trainSoundInterior = new SoundInstance(Content.GetSound("trainSpeed0.wav"), 1, 0, 15, true);
trainSound = trainSoundExterior;
MainGame.Camera.Center = player.Pos - new Vector2f(0, 90);
}
示例9: BarracksScrollList
//totalbars - maxShown = max topBar
internal BarracksScrollList(Barracks b, Vector2f start)
{
//int x = (overallRect.Height - 2 * 25) / champBarRect.Height;
//scroll = overallRect.Height - (x * champBarRect.Height);
maxShown = (int)((overallRect.Height - 2 * scroll) / champBarRect.Height - 1);
totalBars = b.getTotalChamps();
mBarracks = b;
this.start = start;
disabledButtons = new List<int>();
champsItemIcons = new List<IconToolTip>();
for(int i=0;i<totalBars;i++){
ItemID item = mBarracks.getChamps()[i].item;
Sprite itemS = new Sprite(Item.getItemTexture(item), new IntRect(0, 0, Item.ICON_WIDTH, Item.ICON_WIDTH));
if (item == ItemID.none) {
IconToolTip itt = new IconToolTip(itemS, "none", "none");
champsItemIcons.Add(itt);
} else {
Item ite = new Item(item);
champsItemIcons.Add(new IconToolTip(itemS, ite.name, ite.description));
}
}
champBarSprite = new Sprite(champBarTexture);
unitIconSprite = new Sprite();
topBarDebugText = new Text(topBar + " ",GameBox.corbalFont,30U);
topBarDebugText.Color = Color.Yellow;
playerClassText = new Text("playerclass", GameBox.corbalFont, 15U);
playerItemText = new Text("playeritem", GameBox.corbalFont, 15U);
}
示例10: MapGraphicsComponent
public MapGraphicsComponent(TmxMap Map)
{
var tileWidth = Map.Tilesets.Single().TileWidth;
var tileHeight = Map.Tilesets.Single().TileHeight;
var tileSpacing = Map.Tilesets.Single().Spacing;
var tileMargins = Map.Tilesets.Single().Margin;
texture = new RenderTexture((uint)(Map.Width * tileWidth), (uint)(Map.Height * tileHeight));
foreach (var layer in Map.Layers)
{
foreach (var tile in layer.Tiles)
{
var columns = (int)tileset.Texture.Size.X / (tileWidth + tileSpacing);
int x = (tile.Gid - 1) % columns,
y = (tile.Gid - 1) / columns;
tileset.TextureRect = new IntRect(x * (tileWidth + tileSpacing) + tileMargins,
y * (tileHeight + tileSpacing) + tileMargins, tileWidth,
tileHeight);
tileset.Position = new Vector2f(tile.X * tileWidth, tile.Y * tileHeight);
texture.Draw(tileset);
}
}
texture.Display();
Sprite = new Sprite(texture.Texture);
}
示例11: DrawBot
public void DrawBot(RenderWindow rw)
{
SFML.Graphics.Sprite s = new SFML.Graphics.Sprite(Program.Data.SpriteBasedOnType(SpriteType.Resource)[Program.Data.GetResourceList()[ID].Sprite]);
s.Position = new Vector2f((X + Program.MyMap.MinX) * Program.Data.TileSizeX, (Y + Program.MyMap.MinY) * Program.Data.TileSizeY);
s.TextureRect = new IntRect(0, (int)(s.Texture.Size.Y - Program.Data.GetResourceList()[ID].SizeY * 16), (int)(s.Texture.Size.X), Program.Data.GetResourceList()[ID].SizeY * 16);
rw.Draw(s);
}
开发者ID:ComposerCookie,项目名称:WanderingSoul,代码行数:7,代码来源:SpawnResource+(Jacqueline+Tran's+conflicted+copy+2014-10-27).cs
示例12: drawBeam
internal static void drawBeam(RenderWindow window, Vector2f v1, Vector2f v2, Sprite sprite)
{
Vector2f currentLoc = v1;
int spacingX = 2, spacingY = 2;
//double xNeeded = d.getMid().X - start.X;
//double yNeeded = d.getMid().Y - start.Y;
if (Math.Sign(v1.X - v2.X) > 0) {
spacingX *= -1;
}
if (Math.Sign(v1.Y - v2.Y) > 0) {
spacingY *= -1;
}
bool xGood, yGood;
do{
double d1 = Math.Abs(currentLoc.X - v2.X);
if (!(xGood = (d1 <= Math.Abs(spacingX))))
//double amtMovedX = ((gameTime - startMoveTime) / (travelTime * 1000)) * xNeeded;
currentLoc.X += spacingX;// (float)amtMovedX;
double d2 = Math.Abs(currentLoc.Y - v2.Y);
if (!(yGood = (d2 <= Math.Abs(spacingY))))
//double amtMovedY = ((gameTime - startMoveTime) / (travelTime * 1000)) * yNeeded;
currentLoc.Y += spacingY;//(float)amtMovedY;
sprite.Position = currentLoc;
window.Draw(sprite);
} while (!xGood || !yGood);
}
示例13: Main
public static void Main(String[] args)
{
RenderWindow window = new RenderWindow(new VideoMode(1000, 700), "title");
RenderTexture tex = new RenderTexture(1000, 700);
Sprite texSprite = new Sprite(tex.Texture);
Fractal fractal = new Fractal();
fractal.CreateTreeFractal(500, 700, 3, 100, 0);
Console.WriteLine(fractal.Nodes.Count);
while (window.IsOpen())
{
window.Clear();
tex.Clear(new Color(0, 0, 0, 200
));
foreach (Shape s in fractal.Nodes)
{
window.Draw(s);
}
tex.Display();
window.Draw(texSprite);
window.Display();
Image img = window.Capture();
img.SaveToFile("C:/i.png");
Console.ReadLine();
}
}
示例14: GameStateMultiplayer
public GameStateMultiplayer()
{
_background = new Sprite(ResourceManager.Instance["menu/background"] as Texture);
Game.Instance.AudioManager.PauseAllBackground();
Game.Instance.AudioManager.PlaySound("menu/background_music", true);
PrepareUi();
Game.Instance.Window.MouseButtonReleased += Window_MouseButtonReleased;
try
{
var id = GameClient.Instance.InitConnection();
Game.Instance.Player.Id = id;
}
catch
{
}
if (GameClient.Connected)
{
RefeshGameClick(null, null);
}
}
示例15: GaussianBlurRadius11_ShouldBlur
public void GaussianBlurRadius11_ShouldBlur()
{
preblur = new RenderImage("testGaussianBlur", 1280, 768);
_gaussianBlur = new GaussianBlur(_resourceManager);
_gaussianBlur.SetRadius(11);
_gaussianBlur.SetAmount(2);
_gaussianBlur.SetSize(new Vector2f(preblur.Width, preblur.Height));
while (CluwneLib.IsRunning)
{
var lastFrameTime = clock.ElapsedTime.AsSeconds();
clock.Restart();
_frameEvent = new FrameEventArgs(lastFrameTime);
CluwneLib.ClearCurrentRendertarget(Color.Black);
CluwneLib.Screen.DispatchEvents();
preblur.BeginDrawing(); // set temp as CRT (Current Render Target)
//preblur.Clear(); //Clear
sprite = _resourceManager.GetSprite("flashlight_mask");
sprite.Position = new Vector2f();
sprite.Draw();
preblur.EndDrawing(); // set previous rendertarget as CRT (screen in this case)
//_gaussianBlur.PerformGaussianBlur(preblur); // blur rendertarget
preblur.Blit(0,0, preblur.Width, preblur.Height,Color.White, BlitterSizeMode.Crop ); // draw blurred nosprite logo
CluwneLib.Screen.Display();
}
}