本文整理汇总了C#中FSprite.SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C# FSprite.SetPosition方法的具体用法?C# FSprite.SetPosition怎么用?C# FSprite.SetPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FSprite
的用法示例。
在下文中一共展示了FSprite.SetPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UI
public UI()
{
dialogue = new Dialogue();
this.AddChild(dialogue);
background = new FSprite("bg");
slotA = new FSprite("slot_a");
slotB = new FSprite("slot_b");
slotASelected = new FSprite("jump_soul");
slotBSelected = new FSprite("sword_soul");
hearts = new FSprite("heart_full");
this.AddChild(background);
this.AddChild(slotA);
this.AddChild(slotB);
this.AddChild(slotASelected);
this.AddChild(slotBSelected);
this.AddChild(hearts);
slotASelected.isVisible = false;
slotBSelected.isVisible = false;
background.y = Futile.screen.halfHeight - background.height / 2f;
slotB.y = background.y;
slotA.y = background.y;
slotB.x = -Futile.screen.halfWidth + slotB.width / 2f + 20;
slotA.x = slotB.x + slotB.width / 2f + slotA.width / 2f + 3;
slotASelected.SetPosition(slotA.GetPosition());
slotBSelected.SetPosition(slotB.GetPosition());
slotASelected.x += 1;
slotBSelected.x += 1;
hearts.y = background.y;
hearts.x = Futile.screen.halfWidth - hearts.width / 2f - 20;
}
示例2: TweenTerrain
public TweenTerrain()
{
height = 768;
width = 768;
halfWidth = width/2;
halfHeight = height/2;
TextAsset t = Resources.Load("map") as TextAsset;
IDictionary dict = Json.Deserialize(t.text) as IDictionary;
IList layers = dict["layers"] as IList;
IDictionary layer = layers[0] as IDictionary;
IList data = layer["data"] as IList;
int index = 0;
tiles = new FSprite[((int)height+tileSize)/tileSize,((int)width+tileSize)/tileSize];
for(float y = -halfHeight; y < halfHeight; y+=tileSize){
for(float x = -halfWidth; x < halfWidth; x+=tileSize){
FSprite s = new FSprite(Futile.whiteElement);
if((long)data[index++] == 1)
enablesTiles.Add(s);
s.SetPosition(x,y);
s.scale = 0;
s.alpha = 0;
tiles[(int)(y+halfHeight)/tileSize,(int)(x+halfWidth)/tileSize] = s;
this.AddChild(s);
}
}
Debug.Log(index);
}
示例3: LevelBar
public LevelBar(int numDashes)
{
this.numDashes = numDashes;
string borderElementName = "UI/Stats/LevelBar_" + numDashes;
if (numDashes == 5) {
dashWidth = 19;
} else if (numDashes == 10) {
dashWidth = 9;
} else if (numDashes == 25) {
dashWidth = 3;
}
AddChild (barContainer = new FContainer ());
barContainer.AddChild (background = new FSprite ("Box")); //black bg
background.color = Color.black;
background.SetAnchor (0.0f, 0.0f);
barContainer.AddChild (borderSprite = new FSprite (borderElementName));//white border
borderSprite.SetAnchor (0.0f, 0);
borderSprite.SetPosition (0, 0);
barContainer.AddChild (dashContainer = new FContainer ());
dashSpacing = 1;
totalWidth = 100;
dashHeight = 3;
barOffset = new Vector2 (-51, 0);
dashOffset = new Vector2 (1, 2);
ApplyConfig ();
}
示例4: GamePage
public GamePage()
{
HeadsUpDisplay = new FContainer();
Debug.Log("In game page");
FSprite bg = new FSprite("Futile_White");
bg.color = Color.black;
bg.width = Futile.screen.width;
bg.height = Futile.screen.height;
AddChild(bg);
bg.SetPosition(new Vector2(Futile.screen.width / 2, Futile.screen.height/2));
}
示例5: NewPlayerBox
public NewPlayerBox()
{
base.Init(Player.NullPlayer);
contentContainer.AddChild(bodySprite = new FSprite("Icons/NewPlayer_Body"));
contentSprites.Add(bodySprite);
bodySprite.color = Color.black;
contentContainer.AddChild(plusSprite = new FSprite("Icons/NewPlayer_Plus"));
contentSprites.Add(plusSprite);
plusSprite.color = Color.black;
plusSprite.SetPosition(0.0f,7.0f);
}
示例6: AddHealth
public void AddHealth(int health, Vector2 pos)
{
for (int i = this.health; i < health; i++)
{
FSprite heart = new FSprite("heart");
heart.SetPosition(pos);
Vector2 targetPos = hearts.GetPosition();
switch (i)
{
case 0: targetPos.x -= 10; break;
case 1: break;
case 2: targetPos.x += 10; break;
}
this.AddChild(heart);
Go.to(heart, .7f, new TweenConfig().floatProp("x", targetPos.x).floatProp("y", targetPos.y).setEaseType(EaseType.QuadOut).onComplete(() => { setHealthSprite(this.health); heart.RemoveFromContainer(); }));
}
this.health = health;
}
示例7: Start
// Use this for initialization
public override void Start()
{
Background = new FSprite("Futile_White");
Background.width = Futile.screen.width;
Background.height = Futile.screen.height;
Background.SetPosition(new Vector2(Futile.screen.halfWidth, Futile.screen.halfHeight));
AddChild(Background);
TextureA = new FSprite("Futile_White");
TextureA.color = Color.yellow;
TextureA.SetPosition(new Vector2(Futile.screen.halfWidth, Futile.screen.halfHeight));
AddChild(TextureA);
TextureB = new FSprite("Futile_White");
TextureB.color = Color.red;
TextureB.SetPosition(new Vector2(Futile.screen.halfWidth, Futile.screen.halfHeight));
AddChild(TextureB);
ListenForUpdate(Update);
}
示例8: Start
// Use this for initialization
void Start()
{
// Set up Futile.
FutileParams fParams = new FutileParams(true, true, false, false);
fParams.AddResolutionLevel(1024.0f, 1.0f, 1.0f, "");
Futile.instance.Init(fParams);
// Load assets.
FAnimationManager.Instance.LoadAtlas(MY_ATLAS_PATH);
FContainer container = new FContainer();
FSprite sprite = new FSprite(FSPRITE_ID);
sprite.SetPosition(-100,0);
//setup the animation sprite
aSprite = new FAnimSprite(FANIM_ID);
aSprite.SetPosition(100, 0);
Futile.stage.AddChild(container);
container.AddChild(sprite);
container.AddChild(aSprite);
}
示例9: UI
public UI(World w)
{
this.w = w;
for (int i = 0; i < MAX_HEALTH; i++)
{
hearts[i] = new FSprite("heart");
hearts[i].x = Futile.screen.halfWidth - hearts[i].width / 2f - uiSideMargin - (i * (hearts[i].width + heartSpace));
hearts[i].y = Futile.screen.halfHeight - hearts[i].height / 2f - uiSideMargin;
this.AddChild(hearts[i]);
}
selectedPowerupBG = new FSprite("powerupSelect");
selectedPowerupBG.x = -Futile.screen.halfWidth + selectedPowerupBG.width / 2f + uiSideMargin + 20;
selectedPowerupBG.y = hearts[0].y;
this.AddChild(selectedPowerupBG);
selectedPowerup = new FSprite("normalpowerup");
selectedPowerup.SetPosition(selectedPowerupBG.GetPosition());
this.AddChild(selectedPowerup);
killCount = new FLabel(C.smallFontName, "0");
killCount.y = Futile.screen.halfHeight - killCount.textRect.height / 2f - uiSideMargin;
this.AddChild(killCount);
}
示例10: Start
public override void Start()
{
// once play navigates away from home screen, don't play the intro when they return
Main.instance.playIntro = false;
Main.instance.crewSaved = 0;
FSprite background = new FSprite("mainGameViewport");
background.SetAnchor(0.0f, 0.0f);
AddChild(background);
_levelManager = new LevelManager();
AddChild(_levelManager);
this.shouldSortByZ = true;
meltdownBar = new FSprite("meltdown");
meltdownBar.SetPosition(Futile.screen.halfWidth, 672);
AddChild(meltdownBar);
_closeButton = new FButton("button");
_closeButton.AddLabel("Emulogic","Quit",Color.black);
_closeButton.label.scale = 0.25f;
_closeButton.sortZ = 1;
_closeButton.SignalRelease += HandleCloseButtonRelease;
_closeButton.x = Futile.screen.width - 125.0f;
_closeButton.y = Futile.screen.height -75.0f;
AddChild(_closeButton);
Clock clock = new Clock();
clock.SetPosition( 75.0f, Futile.screen.height - 75.0f);
AddChild(clock);
crewSavedLabel = new FLabel("Emulogic", "Crew Members Saved: 0");
crewSavedLabel.SetPosition( Futile.screen.halfWidth, Futile.screen.height - 45.0f);
crewSavedLabel.scale = 0.25f;
AddChild(crewSavedLabel);
selectedInventory = new FSprite("inventorySelected");
selectedInventory.isVisible = false;
AddChild(selectedInventory);
//spawnInventory();
spawnCrew(2);
_lastCycle = Main.GameTime;
}
示例11: InitBeasts
void InitBeasts()
{
List<Player> players = GameManager.instance.activePlayers;
float radiansPerPlayer = RXMath.DOUBLE_PI / (float)players.Count;
float startRadius = 150.0f;
for (int p = 0; p < players.Count; p++)
{
Vector2 startPos = new Vector2();
startPos.x = Mathf.Cos(p * radiansPerPlayer) * startRadius;
startPos.y = Mathf.Sin(p * radiansPerPlayer) * startRadius;
Beast beast = Beast.Create(this);
beast.Init(players[p], startPos);
beasts.Add(beast);
FSprite beastShadow = new FSprite("Evil-Eye_Shadow_1");
beastShadowHolder.AddChild(beastShadow);
beastShadow.SetPosition(beast.GetPos());
beastShadow.rotation = beast.holder.rotation;
beastShadow.alpha = 0.7f;
beastShadow.scale = 1.0f;
beast.shadow = beastShadow;
}
for(int t = 0; t<teams.Count; t++)
{
Team team = teams[t];
team.SignalTeamChange += HandleSignalTeamChange;
}
int linkCount = 11;
if (beasts.Count == 2)
{
linkCount = 11;
chains.Add(new Chain(this, 11, beasts[0], beasts[1]));
}
else if (beasts.Count == 3)
{
chains.Add(new Chain(this, 11, beasts[0], beasts[1]));
chains.Add(new Chain(this, 11, beasts[1], beasts[2]));
chains.Add(new Chain(this, 11, beasts[2], beasts[0]));
}
else if (beasts.Count == 4)
{
linkCount = 13;
//chains.Add(new Chain(this, 11, beasts[0], beasts[1]));
//chains.Add(new Chain(this, 11, beasts[1], beasts[2]));
//chains.Add(new Chain(this, 11, beasts[2], beasts[3]));
//chains.Add(new Chain(this, 11, beasts[3], beasts[0]));
chains.Add(new Chain(this, linkCount, beasts[0], beasts[2]));
chains.Add(new Chain(this, linkCount, beasts[1], beasts[3]));
Chain ca = chains[0];
Chain cb = chains[1];
int middleLink = (linkCount-1)/2;
ChainLink linkA = ca.links[middleLink];
ChainLink linkB = cb.links[middleLink];
linkA.gameObject.transform.position = new Vector2(0,0).ToVector3InMeters();
linkB.gameObject.transform.position = new Vector2(0,0).ToVector3InMeters();
HingeJoint hinge = linkA.gameObject.AddComponent<HingeJoint>();
hinge.connectedBody = linkB.rigidbody;
JointSpring jspring = hinge.spring;
jspring.spring = 0.1f;
hinge.spring = jspring;
hinge.axis = new Vector3(0.0f, 0.0f, 1.0f);
}
for(int b = 0; b<beasts.Count; b++)
{
beasts[b].holder.MoveToFront();
}
}
示例12: Start
public override void Start()
{
Main.instance.crewSaved = 0;
Main.instance.gameFinished = false;
FSprite background = new FSprite("viewport");
background.SetAnchor(0.0f, 0.0f);
AddChild(background);
_introLabel = new FLabel("Emulogic", "");
_introLabel.color = Color.black; //Color.green; // new Color(0.173f, 0.722f, 0.976f, 1.0f);
_introLabel.scale = 0.2f;
_introLabel.SetAnchor(0.0f, 1.0f);
_introLabel.SetPosition(60, Futile.screen.height - 14);
AddChild(_introLabel);
_titleLabel = new FLabel("Emulogic", "");
_titleLabel.color = Color.black;
_titleLabel.scale = 1.0f;
_titleLabel.SetAnchor(0.0f, 1.0f);
_titleLabel.SetPosition(200, 550);
AddChild(_titleLabel);
_finalLabel = new FLabel("Emulogic", "");
_finalLabel.color = Color.black; //Color.green;
_finalLabel.scale = 0.2f;
_finalLabel.SetAnchor(0.0f, 1.0f);
_finalLabel.SetPosition(575, 400);
AddChild(_finalLabel);
if (!Main.instance.playIntro){
_introLabel.text = _introText;
_titleLabel.text = _titleText;
_finalLabel.text = _finalText;
}
_startButton = new FButton("buttonWide");
_startButton.AddLabel("Emulogic","Play!",Color.black); //new Color(0.45f,0.25f,0.0f,1.0f)
_startButton.label.scale = 0.25f;
_startButton.SetPosition(Futile.screen.width - 225, 155);
AddChild(_startButton);
_startButton.SignalRelease += HandleStartButtonRelease;
_creditsButton = new FButton("buttonWide");
_creditsButton.AddLabel("Emulogic","About",Color.black); //new Color(0.45f,0.25f,0.0f,1.0f)
_creditsButton.label.scale = 0.25f;
_creditsButton.SetPosition(Futile.screen.width - 225, 75);
AddChild(_creditsButton);
_creditsButton.SignalRelease += HandleCreditsButtonRelease;
_lastTextUpdate = Main.GameTime;
FSprite escapePod = new FSprite("escapePod");
FSprite doors = new FSprite("doorsIcon");
FSprite crew = new FSprite("floatingCharacter");
FSprite clock = new FSprite("moveTileIcon");
//FSprite clock = new FSprite("clock4");
escapePod.scale = 0.5f;
doors.scale = 0.5f;
escapePod.SetPosition(140, 305);
doors.SetPosition(140, 230);
crew.SetPosition(140, 155);
clock.SetPosition(140, 80);
AddChild(escapePod);
AddChild(doors);
AddChild(crew);
AddChild(clock);
FLabel escapePodLabel = new FLabel("Emulogic", "Get the crew to \nthe escape pods!");
escapePodLabel.color = Color.black; //Color.green;
escapePodLabel.scale = 0.15f;
escapePodLabel.SetAnchor(0.0f, 0.5f);
escapePodLabel.SetPosition(200, 305);
AddChild(escapePodLabel);
FLabel doorsLabel = new FLabel("Emulogic", "Touch doors to \nopen and close them.");
doorsLabel.color = Color.black; //Color.green;
doorsLabel.scale = 0.15f;
doorsLabel.SetAnchor(0.0f, 0.5f);
doorsLabel.SetPosition(200, 230);
AddChild(doorsLabel);
FLabel crewLabel = new FLabel("Emulogic", "The Crew. They will walk \nthrough open doors, \nbut don't expect much else.");
crewLabel.color = Color.black; //Color.green;
crewLabel.scale = 0.15f;
crewLabel.SetAnchor(0.0f, 0.5f);
crewLabel.SetPosition(200, 155);
AddChild(crewLabel);
FLabel clockLabel = new FLabel("Emulogic", "Place movement tiles \nto redirect the crew.");
//FLabel clockLabel = new FLabel("Emulogic", "10 Seconds.");
clockLabel.color = Color.black; //Color.green;
//.........这里部分代码省略.........
示例13: loadTiles
void loadTiles()
{
foreach (PlatformData platform in levelData.getPlatformData())
{
FSprite plat = new FSprite(platform.image);
plat.height = 16;
plat.width = 16;
tileSize = plat.width;
Tiles[(int)platform.x, (int)platform.y] = 1;
// make them overlap a little to avoid those ungly lines in the rendering.
plat.SetPosition(new Vector2((platform.x * plat.width), (-platform.y * plat.height)));
AddChild(plat);
}
playerBullets = new List<Bullet>();
hazards = new List<Hazard>();
particleContainer = new FContainer();
AddChild(particleContainer);
enemyContainer = new FContainer();
AddChild(enemyContainer);
particles = new FParticleSystem(50);
particleContainer.AddChild(particles);
projectileContainer = new FContainer();
AddChild(projectileContainer);
entityContainer = new FContainer();
AddChild(entityContainer);
frontContainer = new FContainer();
AddChild(frontContainer);
this.alpha = 0;
TweenConfig tw = new TweenConfig();
tw.floatProp("alpha", 1);
Go.to(this, 10f, tw);
stats = new FLabel("font", "Jump Packs: 0; reload times: 0");
CurrentPage.GetHUD().AddChild(stats);
stats.scale = 0.9f;
stats.SetPosition(new Vector2(Futile.screen.halfWidth, Futile.screen.height * 0.9f));
}
示例14: Rect
public static void Rect(Rect rect, Color color)
{
Draw.rect = rect;
FSprite sprite = new FSprite(Pixel);
SpriteBatch.AddChild(sprite);
sprite.SetAnchor(0, 0);
sprite.SetPosition(rect.x, rect.y);
sprite.width = rect.width;
sprite.height = rect.height;
sprite.color = color;
//SpriteBatch.Draw(Pixel.Texture2D, rect, Pixel.Rect, color);
}
示例15: HandleUpdate
protected void HandleUpdate()
{
float dt = Time.deltaTime;
if (Main.GameTime - _lastCycle > 10){
// spawn some new crew every 10 seconds
spawnInventory();
//if(_crewSpawned < 20){
if (_crewMembers.Count < 10){ // keep spawning crew so long as there arae not more than 10 currently out
spawnCrew(3);
}
_levelManager.scrambleDoors();
int totalMeltdownSegments = 20;
// use 20 for shorter game play (about 3.3 minutes)
// use 32 for shorter game play (about 5.3 minutes)
if (_meltdownSegmentCount < totalMeltdownSegments){
float segmentWidth = 640 / totalMeltdownSegments;
// draw another segment on the meltdown timer
FSprite meltdownSegment = new FSprite("meltdownSegment");
meltdownSegment.width = segmentWidth;
// calculate position
float x = Futile.screen.halfWidth - (meltdownBar.width / 2) + 4 + (segmentWidth / 2); // 4 is to get the spacing right
x += _meltdownSegmentCount * segmentWidth;
meltdownSegment.SetPosition(x, 672);
AddChild(meltdownSegment);
_meltdownSegmentCount++;
} else {
GameOver();
}
_lastCycle = Main.GameTime;
}
// handle input
bool invKeyPressed = false;
if (Input.GetKeyDown(KeyCode.Alpha1)){
invKeyPressed = true;
_invNumSelected = 0;
} else if (Input.GetKeyDown(KeyCode.Alpha2)){
invKeyPressed = true;
_invNumSelected = 1;
} else if (Input.GetKeyDown(KeyCode.Alpha3)){
invKeyPressed = true;
_invNumSelected = 2;
} else if (Input.GetKeyDown(KeyCode.Alpha4)){
invKeyPressed = true;
_invNumSelected = 3;
} else if (Input.GetKeyDown (KeyCode.Escape)){
invKeyPressed = false;
_invNumSelected = -1;
selectedInventory.isVisible = false;
}
if (invKeyPressed){
// so the user selected a valid inventory slot,
// now make sure there is something in that slot
if (_inventory[_invNumSelected] != null){
selectedInventory.SetPosition(positionForInventory(_invNumSelected));
selectedInventory.isVisible = true;
} else {
// they clicked on an empty inventory
_invNumSelected = -1;
}
}
// update crew member's movement direction
//loop backwards so if we remove a crew member from the list, it won't cause problems
for (int i = _crewMembers.Count-1; i >= 0; i--)
{
Crew crewMember = _crewMembers[i];
VectorDirection currentDirection = crewMember.direction;
Vector2 newCrewPosition = crewMember.calculateNewPosition(dt);
if (!_levelManager.crewMemberIsPassingThruDoor(crewMember)){ // passing through a door takes precidence
if (_levelManager.willObeyFloorTile(crewMember, newCrewPosition)){
} else if (_levelManager.willDirectCrewToDoor(crewMember)) { // check if crew member is next to an open door, if so they will be directed to it
if (crewMember.direction != currentDirection){
// direction was updated, don't adjust position
newCrewPosition = crewMember.GetPosition();
}
} else if (!_levelManager.checkCrewHeadingOk(crewMember, newCrewPosition)){
// crew member heading into a wall, so heading was adjusted, don't update position
newCrewPosition = crewMember.GetPosition();
}
}
// update crew member's position (having taken into account all previous checks)
crewMember.SetPosition(newCrewPosition);
// check if crew member is in the escape pod room
int escapePodXMax = (64 * 7) - 32;
int escapePodYMax = (64 * 3) - 32;
if (newCrewPosition.x <= escapePodXMax && newCrewPosition.y <= escapePodYMax){
// you saved this crew member!
FSoundManager.PlaySound("crewSaved1", 0.5f);
Main.instance.crewSaved++;
crewSavedLabel.text = "Crew Members Saved: " + Main.instance.crewSaved;
//.........这里部分代码省略.........