本文整理汇总了C#中SFML.Graphics.Sprite.GetLocalBounds方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.GetLocalBounds方法的具体用法?C# Sprite.GetLocalBounds怎么用?C# Sprite.GetLocalBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFML.Graphics.Sprite
的用法示例。
在下文中一共展示了Sprite.GetLocalBounds方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Aircraft
//constructor
//Possibly requires explicit keyword
public Aircraft(Type type, ResourceHolder<Texture, ResourceID> textures)
{
mType = type;
mSprite = new Sprite(textures.get(toTextureID(type)));
FloatRect bounds = mSprite.GetLocalBounds();
mSprite.Origin = new Vector2f(bounds.Width / 2, bounds.Height / 2);
}
示例2: UnitCell
public UnitCell(Cell targetCell, Cell sourceCell, int units, PlayerInstance player)
{
TargetCell = targetCell;
SourceCell = sourceCell;
Units = UnitsLeft = units;
_currentVelocity = Velocity;
string colorName = null;
if (SourceCell.Player.Color.R == 255 && SourceCell.Player.Color.G == 0 && SourceCell.Player.Color.B == 0)
{
colorName = "red";
}
else if (SourceCell.Player.Color.R == 0 && SourceCell.Player.Color.G == 255 && SourceCell.Player.Color.B == 0)
{
colorName = "green";
}
else if (SourceCell.Player.Color.R == 0 && SourceCell.Player.Color.G == 0
&& SourceCell.Player.Color.B == 255)
{
colorName = "blue";
}
_sprite = new Sprite(ResourceManager.Instance["game/unit_cell_" + colorName] as Texture);
_text = new Text(units.ToString(), ResourceManager.Instance["fonts/verdana"] as Font, FontSize);
_text.Origin = new Vector2f(
_text.GetLocalBounds().Left + _text.GetLocalBounds().Width / 2,
_text.GetLocalBounds().Top);
_particleSystem = new ParticleSystem(ResourceManager.Instance["game/particle"] as Texture);
var scale = 0.5f + Units * 0.0125f;
if (scale >= 1f)
{
scale = 1f;
}
Scale = _initialScale = new Vector2f(scale, scale);
Radius = _sprite.GetGlobalBounds().Height / 2;
_sprite.Origin = new Vector2f(_sprite.GetLocalBounds().Width / 2, _sprite.GetLocalBounds().Height / 2);
SourcePlayer = player;
}
示例3: PlayerShip
/// <summary>
/// Constructor
/// </summary>
/// <param name="resManager">Gestor de recursos</param>
/// <param name="worldBounds">Dimensiones de area de movimiento del PlayerShip</param>
/// <param name="shootPool">Piscina que gestiona el reciclaje de las balas</param>
public PlayerShip(ResourcesManager resManager, FloatRect worldBounds,ShootPlayerPool shootPool)
: base()
{
_sprite = new Sprite((Texture)resManager["Naves:NaveJugador"]);
_worldBounds = worldBounds;
// ubico el origen del sprite en el centro en vez de en la esquina superior derecha
FloatRect bounds = _sprite.GetLocalBounds();
_sprite.Origin = new SFML.System.Vector2f(bounds.Width / 2f, bounds.Height / 2f);
_shootPool = shootPool;
}
示例4: Button
public Button(ResourceHolder<Font, FontID> fonts, ResourceHolder<Texture, ResourceID> textures)
{
//ACTION IS NOT INITIALIZED
mNormalTexture = new Texture(textures.get(ResourceID.ButtonNormal));
mSelectedTexture = new Texture(textures.get(ResourceID.ButtonSelected));
mPressedTexture = new Texture(textures.get(ResourceID.ButtonPressed));
mSprite = new Sprite(mNormalTexture);
mText = new Text("", fonts.get(FontID.Main), 16);
mIsToggle = false;
FloatRect bounds = mSprite.GetLocalBounds();
mText.Position = new Vector2f(bounds.Width / 2, bounds.Height / 2);
}
示例5: ServerSelector
public ServerSelector()
{
_shape.FillColor = Color.Transparent;
_shape.OutlineThickness = 3.0f;
_shape.OutlineColor = Color.White;
_shape.Size = new Vector2f(350, 300);
_shape.Origin = new Vector2f(_shape.Size.X / 2, _shape.Size.Y / 2);
_shape.Position = new Vector2f(Game.Instance.Width / 2, Game.Instance.Height / 2 + _shape.Size.Y);
SelectedLobbyId = -1;
_arrow = new Sprite(ResourceManager.Instance["multiplayer/arrow"] as Texture);
_arrow.Origin = new Vector2f(0, _arrow.GetLocalBounds().Height / 2);
_arrow.Position = new Vector2f(_shape.Position.X - _shape.GetLocalBounds().Width / 2 + 10, 0);
}
示例6: SpritePixelHit
public static bool SpritePixelHit(Sprite toCheck, Vector2f clickPos)
{
var clickPoint = new Vector2f(clickPos.X, clickPos.Y);
if (!toCheck.GetLocalBounds().Contains(clickPoint.X, clickPoint.Y)) return false;
var spritePosition = new Vector2u((uint) clickPos.X - (uint) toCheck.Position.X ,//+ (int) toCheck.ImageOffset.X,
(uint) clickPos.Y - (uint) toCheck.Position.Y ); //+ (int) toCheck.ImageOffset.Y);
Image imgData = toCheck.Texture.CopyToImage();
//imgData.Lock(false);
Color pixColour = imgData.GetPixel(spritePosition.X, spritePosition.Y);
imgData.Dispose();
//imgData.Unlock();
return pixColour.A != 0;
}
示例7: ExamineWindow
public ExamineWindow(Vector2i size, Entity entity, IResourceManager resourceManager)
: base(entity.Name, size, resourceManager)
{
_resourceManager = resourceManager;
_entityDescription = new Label(entity.GetDescriptionString(), "CALIBRI", _resourceManager);
components.Add(_entityDescription);
ComponentReplyMessage reply = entity.SendMessage(entity, ComponentFamily.Renderable,
ComponentMessageType.GetSprite);
SetVisible(true);
if (reply.MessageType == ComponentMessageType.CurrentSprite)
{
_entitySprite = (Sprite) reply.ParamsList[0];
_entityDescription.Position = new Vector2i(10,
(int)_entitySprite.GetLocalBounds().Height +
_entityDescription.ClientArea.Height + 10);
}
else
_entityDescription.Position = new Vector2i(10, 10);
}
示例8: Aircraft
public Aircraft(Type type, ResourceHolder<Texture, ResourceID> textures, ResourceHolder<Font,FontID> fonts) :base(Table[(int)type].hitpoints)
{
mType = type;
mSprite = new Sprite(textures.get(toTextureID(type)));
FloatRect bounds = mSprite.GetLocalBounds();
mSprite.Origin = new Vector2f(bounds.Width / 2, bounds.Height / 2);
TextNode healthDisplay = new TextNode(fonts, " "); ;
mHealthDisplay = healthDisplay;
attachChild(healthDisplay);
mTravelledDistance = 0;
mDirectionIndex = 0;
mIsFiring = false;
mIsLaunchingMissile = false;
MissileAmmo = 3;
mIsMarkedForRemoval = false;
mFireCountdown = Time.Zero;
mFireRateLevel = 1;
mSpreadLevel = 1;
mFireCommand = new Command();
mFireCommand.category = (uint)Category.PlayerAircraft;
mFireCommand.actionfunc = (SceneNode node, Time time) =>
{
SceneNode aircraft = (Aircraft)node;
createBullets(aircraft, textures);
};
mLaunchCommand = new Command();
}
示例9: Blit
/// <summary>
/// Creates a Sprite from RenderImage Texture and draws it to the screen
/// </summary>
/// <param name="Position"> Position of Texture </param>
/// <param name="Size"> Size of the Texture </param>
/// <param name="color"> Global color of object </param>
public void Blit(SFML.System.Vector2f position, SFML.System.Vector2f Size, SFML.Graphics.Color color)
{
isStillDrawing();
blitsprite = new SFML.Graphics.Sprite(Texture);
blitsprite.Position = position;
blitsprite.Color = color;
var bounds = blitsprite.GetLocalBounds();
if (Mode == BlitterSizeMode.Scale)
{
SFML.System.Vector2f scale = new SFML.System.Vector2f(( Size.X / bounds.Width ),( Size.Y / bounds.Height ));
blitsprite.Scale = scale;
}
else if (Mode == BlitterSizeMode.Crop)
{
IntRect crop = new IntRect((int)position.X, (int)position.Y, (int)Size.X, (int)Size.Y);
blitsprite.TextureRect = crop;
}
if (CluwneLib.CurrentRenderTarget == this)
return;
blitsprite.Draw();
}
示例10: Draw
public void Draw(Vector2f position, Vector2f windowOrigin, Sprite spriteToDrawAbove)
{
if ((DateTime.Now - _buildTime).TotalMilliseconds >= MillisecondsToLive) return;
var bubbleBounds = _bubbleSprite.GetLocalBounds();
var spriteBounds = spriteToDrawAbove.GetLocalBounds();
float x = position.X - windowOrigin.X - (bubbleBounds.Width / 2.0f);
float y = position.Y - windowOrigin.Y - (bubbleBounds.Height) - (spriteBounds.Height / 2.0f) - 5.0f;
_bubbleSprite.Position = new Vector2f(x, y);
_bubbleSprite.Draw();
}
示例11: Shoot
public Shoot(Type type)
: base()
{
_type = type;
_sprite = new Sprite((Texture)ShootTypeConf[(int)_type]._resManager[ShootTypeConf[(int)_type]._textureKey]);
_sprite.Scale = new Vector2f(0.7f, 0.7f);
// ubico el origen del sprite en el centro en vez de en la esquina superior izquierda
FloatRect bounds = _sprite.GetLocalBounds();
_sprite.Origin = new SFML.System.Vector2f(bounds.Width / 2f, bounds.Height / 2f);
VelocityY = ShootTypeConf[(int)_type]._maxSpeed;
_collider = new ColliderRect(bounds, new SFML.System.Vector2f(bounds.Width / 2f, bounds.Height / 2f));
}