/// <summary> /// Анимация счета за уничтожение цепочки /// </summary> /// <param name="chain">Уничтожаемая цепочка.</param> private void AnimateScore(GemList chain) { SKSpriteNode firstGem = chain.GetFirstGem().Sprite; SKSpriteNode lastGem = chain.GetLastGem().Sprite; CGPoint centerPoint = new CGPoint( (firstGem.Position.X + lastGem.Position.X) / 2, (firstGem.Position.Y + lastGem.Position.Y) / 2 - 8); SKLabelNode scoreLabel = new SKLabelNode("GillSans-BoldItalic") { FontSize = 16, Text = chain.GetScore() + "", Position = centerPoint, ZPosition = 300 }; gemLayer.AddChild(scoreLabel); SKAction moveAction = SKAction.MoveBy(0, 3, 0.7); //.Move(by: CGVector(dx: 0, dy: 3), duration: 0.7) moveAction.TimingMode = SKActionTimingMode.EaseOut; scoreLabel.RunAction(SKAction.Sequence(moveAction, SKAction.RemoveFromParent())); }
public ResultsScreen (CGSize size) : base (size) { var timeLabel = new SKLabelNode ("GillSans-Bold") { Text = "Time: " + GameInfo.GameTimeInSeconds, FontSize = 24, Position = new CGPoint (FrameMidX, FrameMidY + 120) }; var modeLabel = new SKLabelNode ("GillSans-Bold") { Text = "Mode: " + GameInfo.GameMode, FontSize = 24, Position = new CGPoint (FrameMidX, FrameMidY + 60) }; var scoreLabel = new SKLabelNode ("GillSans-Bold") { Text = "Score: " + GameInfo.CurrentTaps, FontSize = 30, Position = new CGPoint (FrameMidX, FrameMidY) }; doneButton = new SKLabelNode ("GillSans-Bold") { Text = "Done", FontSize = 24, FontColor = ButtonColor, Position = new CGPoint (FrameMidX, FrameMidY - 90) }; AddChild (timeLabel); AddChild (modeLabel); AddChild (scoreLabel); AddChild (doneButton); }
// Queries the root node for the expected nodes. internal GameNodes (SCNNode sceneRoot) { Object = sceneRoot.FindChildNode ("teapot", true); if (Object == null) throw new InvalidProgramException (); ObjectMaterial = Object.Geometry?.FirstMaterial; if (ObjectMaterial == null) throw new InvalidProgramException (); Confetti = sceneRoot.FindChildNode ("particles", true); if (Confetti == null) throw new InvalidProgramException (); Camera = sceneRoot.FindChildNode ("camera", true).Camera; if (Camera == null) throw new InvalidProgramException (); CountdownLabel = new SKLabelNode ("Chalkduster") { HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Center }; CongratulationsLabel = new SKLabelNode ("Chalkduster") { FontColor = GameColors.DefaultFont, Text = "You Win!", FontSize = 45 }; }
public InGameScene(CGSize size) : base(size) { BackgroundColor = AppKit.NSColor.FromCalibratedRgba(0.15f, 0.15f, 0.3f, 1f); timeLabel = LabelWithText("Time", 24); AddChild(timeLabel); CGRect af = timeLabel.CalculateAccumulatedFrame(); timeLabel.Position = new CGPoint(Frame.Size.Width - af.Size.Width, Frame.Size.Height - (af.Size.Height)); timeLabelValue = LabelWithText("102:00", 20); AddChild(timeLabelValue); CGRect timeLabelValueSize = timeLabelValue.CalculateAccumulatedFrame(); timeLabelValue.Position = new CGPoint(Frame.Size.Width - af.Size.Width - timeLabelValueSize.Size.Width - 10, Frame.Size.Height - af.Size.Height); scoreLabel = LabelWithText("Score", 24); AddChild(scoreLabel); af = scoreLabel.CalculateAccumulatedFrame(); scoreLabel.Position = new CGPoint(af.Size.Width * 0.5f, Frame.Size.Height - af.Size.Height); scoreLabelValue = LabelWithText("0", 24); AddChild(scoreLabelValue); scoreLabelValue.Position = new CGPoint(af.Size.Width * 0.75f + (timeLabelValueSize.Size.Width), Frame.Size.Height - af.Size.Height); // Add drop shadows to each label above. timeLabelValueShadow = DropShadowOnLabel(timeLabelValue); timeLabelShadow = DropShadowOnLabel(timeLabel); scoreLabelShadow = DropShadowOnLabel(scoreLabel); scoreLabelValueShadow = DropShadowOnLabel(scoreLabelValue); }
public override void DidMoveToView(SKView view) { this.BackgroundColor = UIColor.Black; AddChild(new SKLabelNode("Chalkduster") { Text = "NAWAGAMISAMA", FontSize = 40, Position = new CGPoint(Frame.Width / 2, Frame.Height - 50) }); var w = View.Frame.Width / 3; _kumaSize = new CGSize(w, w); _effectSize = new CGSize(w + 100, w + 100); _kumaList = new ArrayList(); for (var y = 0; y < 3; y++) { for (var x = 0; x < 3; x++) { _kumaList.Add(new Kuma(this, new CGPoint(x * w, y * w + 150), _kumaSize)); } } _scoreLabel = new SKLabelNode("Chalkduster") { FontSize = 50, Position = new CGPoint(Frame.Width / 2, 50) }; AddChild(_scoreLabel); }
public ResultsScreen(CGSize size) : base(size) { var timeLabel = new SKLabelNode("GillSans-Bold") { Text = "Time: " + GameInfo.GameTimeInSeconds, FontSize = 24, Position = new CGPoint(FrameMidX, FrameMidY + 120) }; var modeLabel = new SKLabelNode("GillSans-Bold") { Text = "Mode: " + GameInfo.GameMode, FontSize = 24, Position = new CGPoint(FrameMidX, FrameMidY + 60) }; var scoreLabel = new SKLabelNode("GillSans-Bold") { Text = "Score: " + GameInfo.CurrentTaps, FontSize = 30, Position = new CGPoint(FrameMidX, FrameMidY) }; doneButton = new SKLabelNode("GillSans-Bold") { Text = "Done", FontSize = 24, FontColor = ButtonColor, Position = new CGPoint(FrameMidX, FrameMidY - 90) }; AddChild(timeLabel); AddChild(modeLabel); AddChild(scoreLabel); AddChild(doneButton); }
private void Win() { state = State.Win; ShowMines(-1); var background = new SKShapeNode(); var p = new CGPath(); p.MoveToPoint(0, 0); p.AddLineToPoint(40 * 19, 0); p.AddLineToPoint(40 * 19, 40 * 13); p.AddLineToPoint(0, 40 * 13); p.AddLineToPoint(0, 0); background.Path = p; background.FillColor = NSColor.FromCalibratedRgba(1.0f, 1.0f, 1.0f, 0.7f); AddChild(background); var label = new SKLabelNode("Arial"); label.Text = "Win"; label.FontColor = NSColor.FromCalibratedRgb(0.0f, 0.502f, 0.0f); label.FontSize = 40; label.Position = new CGPoint(40 * 19 / 2, 40 * 13 / 2); label.VerticalAlignmentMode = SKLabelVerticalAlignmentMode.Center; label.HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Center; AddChild(label); }
public Hud(GameController controller) { this.controller = controller; HPBar = new LineBar( controller, new CGPoint(160, controller.Scene.Size.Height - 50), NSColor.Orange) { StrTemplate = "HP:" }; ShieldsBar = new LineBar( controller, new CGPoint(160, controller.Scene.Size.Height - 100), NSColor.Purple) { StrTemplate = "Shields:" }; ScoreLabel = new SKLabelNode { FontColor = NSColor.White, FontName = "Arial", FontSize = 20, Text = $"Score: {controller.PlayerScore}", ZPosition = 1, Position = new CGPoint(HPBar.Label.Position.X + 200, HPBar.Label.Position.Y) }; controller.Scene.AddChild(ScoreLabel); }
public InGameScene (CGSize size) : base (size) { BackgroundColor = AppKit.NSColor.FromCalibratedRgba (0.15f, 0.15f, 0.3f, 1f); timeLabel = LabelWithText ("Time", 24); AddChild (timeLabel); CGRect af = timeLabel.CalculateAccumulatedFrame (); timeLabel.Position = new CGPoint (Frame.Size.Width - af.Size.Width, Frame.Size.Height - (af.Size.Height)); timeLabelValue = LabelWithText ("102:00", 20); AddChild (timeLabelValue); CGRect timeLabelValueSize = timeLabelValue.CalculateAccumulatedFrame (); timeLabelValue.Position = new CGPoint (Frame.Size.Width - af.Size.Width - timeLabelValueSize.Size.Width - 10, Frame.Size.Height - af.Size.Height); scoreLabel = LabelWithText ("Score", 24); AddChild (scoreLabel); af = scoreLabel.CalculateAccumulatedFrame (); scoreLabel.Position = new CGPoint (af.Size.Width * 0.5f, Frame.Size.Height - af.Size.Height); scoreLabelValue = LabelWithText ("0", 24); AddChild (scoreLabelValue); scoreLabelValue.Position = new CGPoint (af.Size.Width * 0.75f + (timeLabelValueSize.Size.Width), Frame.Size.Height - af.Size.Height); // Add drop shadows to each label above. timeLabelValueShadow = DropShadowOnLabel (timeLabelValue); timeLabelShadow = DropShadowOnLabel (timeLabel); scoreLabelShadow = DropShadowOnLabel (scoreLabel); scoreLabelValueShadow = DropShadowOnLabel (scoreLabelValue); }
void InitializeGameView() { currentScore = new SKLabelNode("ArialRoundedMTBold"); currentScore.ZPosition = 1; currentScore.Position = new CGPoint( x: Frame.GetMidX(), y: Frame.GetMidY() + (Frame.Size.Height / -2f) + 60); currentScore.FontSize = 20; currentScore.Hidden = true; currentScore.Text = "Score: 0"; currentScore.FontColor = UIColor.White; AddChild(currentScore); var width = Frame.Size.Width - 94; var height = Frame.Size.Height - 106; var rect = new CGRect( x: Frame.GetMidX() - width / 2f, y: Frame.GetMidY() - height / 2f + 40, width: width, height: height); gameBG = SKShapeNode.FromRect(rect: rect, cornerRadius: 0.02f); gameBG.FillColor = UIColor.DarkGray; gameBG.ZPosition = 2; gameBG.Hidden = true; AddChild(gameBG); CreateGameBoard(width: width, height: height); }
public void setupFailedScreen() { nextLevelButton.RemoveFromParent(); var fLabel = new SKLabelNode { FontName = "GillSans-Bold", FontColor = UIColor.White, FontSize = 40, Position = new CGPoint(Size.Width / 2, Size.Height - 150), Text = "You Lose!", }; var tLabel = new SKLabelNode { FontName = "GillSans-Bold", FontSize = 25, FontColor = UIColor.White, Position = new CGPoint(Size.Width / 2, Size.Height / 2), Text = "Time to beat: " + GameObj.ToBeatScore, }; AddChild(restartButton); AddChild(fLabel); AddChild(tLabel); }
public void ShowScanAction() { var size = base.Size; _scanText1 = new SKLabelNode("AppleSDGothicNeo-Regular") { Text = "Move your phone", FontSize = 30, Position = new CGPoint(size.Width / 2, 100), Color = UIColor.White, }; AddChild(_scanText1); _scanText2 = new SKLabelNode("AppleSDGothicNeo-Regular") { Text = "to find a surface", FontSize = 30, Position = new CGPoint(size.Width / 2, 70), Color = UIColor.White, }; AddChild(_scanText2); _phone = SKSpriteNode.FromImageNamed("phone_scaled"); _phone.Position = new CGPoint(size.Width / 2, 190); var circle = UIBezierPath.FromRoundedRect(new CGRect(new CGPoint(size.Width / 2 - 20, 190), new CGSize(40, 40)), 20); var moveAlongPath = SKAction.RepeatActionForever(SKAction.FollowPath(circle.CGPath, false, false, 2.0)); _phone.RunAction(moveAlongPath); AddChild(_phone); ScanActionShowing = true; ScanActionFinished = false; }
public LeaderboardScoresScreen(CGSize size) : base(size) { SKLabelNode title = new SKLabelNode("GillSans-Bold") { Text = GameInfo.CurrentLeaderBoard.Title, FontSize = 14, Position = new CGPoint(FrameMidX, FrameMidY + 190) }; var podiumSprite = SKSpriteNode.FromTexture(SKTexture.FromImageNamed("Images/Podium.png")); podiumSprite.Position = new CGPoint(FrameMidX, FrameMidY + 50); backButton = new SKLabelNode("GillSans-Bold") { Text = "Back", FontSize = 18, FontColor = ButtonColor, Position = new CGPoint(FrameMidX, FrameMidY - 200) }; if (GKLocalPlayer.LocalPlayer.Authenticated) { LoadLeaderboardScoresInfo(GameInfo.CurrentLeaderBoard); } AddChild(title); AddChild(backButton); AddChild(podiumSprite); }
void DisplayScore(GKScore score, int rank, GKPlayer player) { CGPoint[] podiumPositions = new CGPoint[] { new CGPoint(0, 100), new CGPoint(-84, 75), new CGPoint(84, 50) }; CGPoint currentPoint = podiumPositions [rank]; SKLabelNode scoreLabel = new SKLabelNode("GillSans-Bold") { Text = score.FormattedValue, FontSize = 14, Position = new CGPoint(FrameMidX + currentPoint.X, FrameMidY + currentPoint.Y - 32) }; player.LoadPhoto(GKPhotoSize.Small, delegate(UIImage photo, NSError error) { if (photo == null) { photo = UIImage.FromFile("Images/DefaultPlayerPhoto.png"); } var image = SKSpriteNode.FromTexture(SKTexture.FromImage(photo), new CGSize(32, 32)); image.Position = new CGPoint(FrameMidX + currentPoint.X, FrameMidY + currentPoint.Y + 16); AddChild(image); }); AddChild(scoreLabel); }
void updateHUDFor(Player player) { int playerIndex = players.IndexOf(player); SKLabelNode label = hudScores [playerIndex]; label.Text = string.Format("SCORE: {0}", player.Score); }
public LeaderboardsScreen(CGSize size) : base(size) { leaderboardButtons = new List <SKLabelNode> (); var title = new SKLabelNode("GillSans-Bold") { Text = "Leaderboards", FontSize = 30, Position = new CGPoint(FrameMidX, FrameMidY + 190) }; backButton = new SKLabelNode("GillSans-Bold") { Text = "Back", FontSize = 18, FontColor = ButtonColor, Position = new CGPoint(FrameMidX, FrameMidY - 200) }; if (GKLocalPlayer.LocalPlayer.Authenticated) { GameInfo.CurrentSet.LoadLeaderboards(LoadLeaderboard); } AddChild(title); AddChild(backButton); }
public Slider(int width, int height, string text) : base() { // create a label var fontName = "Optima-ExtraBlack"; this.label = SKLabelNode.FromFont(fontName); this.label.Text = text; this.label.FontSize = 18; this.label.FontColor = SKColor.White; this.label.Position = new CGPoint(0f, -8f); // create background & slider this.background = new SKSpriteNode(SKColor.White, new CGSize(width, 2f)); this.slider = SKShapeNode.FromCircle(height); this.slider.FillColor = SKColor.White; this.background.AnchorPoint = new CGPoint(0f, 0.5f); this.slider.Position = new CGPoint(this.label.Frame.Size.Width / 2f + 15f, 0f); this.background.Position = new CGPoint(this.label.Frame.Size.Width / 2f + 15f, 0f); // add to the root node this.AddChild(this.label); this.AddChild(this.background); this.AddChild(this.slider); // track mouse event base.UserInteractionEnabled = true; this.Value = 0f; }
public AchievementsScreen (SizeF size) : base (size) { var title = new SKLabelNode ("GillSans-Bold") { Text = "Achievements", FontSize = 30, Position = new PointF (FrameMidX, FrameMidY + 200) }; backButton = new SKLabelNode ("GillSans-Bold") { Text = "Back", FontSize = 18, FontColor = ButtonColor, Position = new PointF (FrameMidX, FrameMidY - 200) }; var incompleteLabel = new SKLabelNode ("GillSans-Bold") { Text = "Incomplete", FontSize = 18, Position = new PointF (FrameMidX + 75, FrameMidY + 150) }; var completeLabel = new SKLabelNode ("GillSans-Bold") { Text = "Complete", FontSize = 18, Position = new PointF (FrameMidX - 75, FrameMidY + 150) }; if (GKLocalPlayer.LocalPlayer.Authenticated) GKAchievementDescription.LoadAchievementDescriptions (LoadAchievementInfo); AddChild (title); AddChild (incompleteLabel); AddChild (completeLabel); AddChild (backButton); }
public override void DidMoveToView(SKView view) { var messageLabel = new SKLabelNode { Text = $"You {(isWin ? "win" : "loose")}", FontName = "Arial", FontSize = 40, FontColor = NSColor.Black, Position = new CGPoint(Size.Width / 2, Size.Height - 100), ZPosition = 1 }; var PressAnykeyLabel = new SKLabelNode { Text = $"Press any key for restart", FontName = "Arial", FontSize = 40, FontColor = NSColor.Black, Position = new CGPoint(Size.Width / 2, 100), ZPosition = 1 }; AddChild(messageLabel); AddChild(PressAnykeyLabel); }
public LineBar(GameController controller, CGPoint position, NSColor color) { this.controller = controller; this.position = position; this.color = color; MaxLineWidth = 300; MaxlineHeigth = 10; Line = SKShapeNode.FromRect(new CGSize(MaxLineWidth, MaxlineHeigth)); Line.FillColor = color; Line.Position = position; Line.ZPosition = 1; Border = SKShapeNode.FromRect(new CGSize(MaxLineWidth, MaxlineHeigth)); Border.StrokeColor = NSColor.Black; Border.Position = position; Border.ZPosition = 1; Label = new SKLabelNode { FontColor = NSColor.White, FontName = "Arial", FontSize = 20, Text = "txt", ZPosition = 1 }; Label.Position = new CGPoint( Line.Position.X, Line.Position.Y + Label.FontSize / 2); controller.Scene.AddNodes(Line, Border, Label); }
public LeaderboardSetsScreen(SizeF size) : base(size) { leaderboardSetButtons = new List <SKLabelNode> (); SKLabelNode title = new SKLabelNode("GillSans-Bold") { Text = "Leaderboards Sets", FontSize = 30, Position = new PointF(FrameMidX, FrameMidY + 190) }; backButton = new SKLabelNode("GillSans-Bold") { Text = "Back", FontSize = 18, FontColor = ButtonColor, Position = new PointF(FrameMidX, FrameMidY - 200) }; if (GKLocalPlayer.LocalPlayer.Authenticated) { GKLeaderboardSet.LoadLeaderboardSets(LoadLeaderboardSets); } AddChild(title); AddChild(backButton); }
public MainMenu(SizeF size) : base(size) { var title = new SKLabelNode("GillSans-Bold") { Text = "Button Tapper", FontSize = 30f, Position = new PointF(FrameMidX, FrameMidY + 60) }; startButton = new SKLabelNode("GillSans-Bold") { Text = "Start Game", FontSize = 18, FontColor = ButtonColor, Position = new PointF(FrameMidX, FrameMidY) }; gameCenterButton = new SKLabelNode("GillSans-Bold") { Text = "Game Center", FontSize = 18, FontColor = ButtonColor, Position = new PointF(FrameMidX, FrameMidY - 60) }; gameStatsButton = new SKLabelNode("GillSans-Bold") { Text = "Game Stats", FontSize = 18, FontColor = ButtonColor, Position = new PointF(FrameMidX, FrameMidY - 120) }; challengeFriendsButton = new SKLabelNode("GillSans-Bold") { Text = "Challenge Friends", FontSize = 18, FontColor = ButtonColor, Position = new PointF(FrameMidX, FrameMidY - 180) }; playChallengeButton = new SKLabelNode("GillSans-Bold") { Text = "Play Challenge", FontSize = 18, FontColor = ButtonColor, Position = new PointF(FrameMidX, FrameMidY - 240) }; SetupChallenge(); AddChild(title); AddChild(startButton); AddChild(gameCenterButton); AddChild(gameStatsButton); AddChild(challengeFriendsButton); AddChild(playChallengeButton); }
public PauseMenu(CGSize frameSize) { myLabel = InGameScene.LabelWithText("Resume", 65); myLabel.Position = new CGPoint(Frame.GetMidX(), Frame.GetMidY()); Position = new CGPoint(frameSize.Width * 0.5f, frameSize.Height * 0.5f); AddChild(myLabel); InGameScene.DropShadowOnLabel(myLabel); }
public void textScaling(SKLabelNode scaled) { var up = SKAction.ScaleBy(1.2f, 0.8f); //var down = SKAction.ScaleBy (0.8f, 0.5f); var seq = SKAction.Sequence(new SKAction[] { up, up.ReversedAction }); //({up,down}); var fort = SKAction.RepeatActionForever(seq); scaled.RunAction(fort); }
public PauseMenu (CGSize frameSize) { myLabel = InGameScene.LabelWithText ("Resume", 65); myLabel.Position = new CGPoint (Frame.GetMidX (), Frame.GetMidY ()); Position = new CGPoint (frameSize.Width * 0.5f, frameSize.Height * 0.5f); AddChild (myLabel); InGameScene.DropShadowOnLabel (myLabel); }
public static SKLabelNode AddDescription(this SKNode self, string description, PointF position) { SKLabelNode label = new SKLabelNode ("Helvetica") { Text = description, FontSize = 18, Position = position }; self.AddChild (label); return label; }
public override void DidMoveToView(SKView view) { // Setup your scene here player = new Player(Frame.Width, Frame.Height); AddChild(player.Sprite); infoLabel = CreateInfoLabel(); scoreLabel = CreateScoreLabel(); highscoreLabel = CreateHighscoreLabel(); PhysicsWorld.DidBeginContact += DidBeginContact; }
void LoadAchievementInfo(GKAchievementDescription[] descriptions, NSError error) { if (descriptions == null) { return; } GKAchievement.LoadAchievements(delegate(GKAchievement[] achievements, NSError err) { int completeOffset = 0; int incompleteOffset = 0; foreach (var description in descriptions) { bool completed = false; foreach (var achievement in achievements) { if (description.Identifier == achievement.Identifier) { completed |= achievement.Completed; } } int xOffset = completed ? -75 : 75; int yOffset = completed ? completeOffset : incompleteOffset; var achievementLabel = new SKLabelNode("GillSans-Bold") { Text = description.Title, FontSize = 10, Position = new CGPoint(FrameMidX + xOffset, FrameMidY + 50 + yOffset + 25) }; AddChild(achievementLabel); description.LoadImage(delegate(UIImage image, NSError imageError) { if (image == null) { image = UIImage.FromFile("Images/DefaultPlayerPhoto.png"); } var sprite = SKSpriteNode.FromTexture(SKTexture.FromImage(image), new CGSize(32, 32)); sprite.Position = new CGPoint(FrameMidX + xOffset, FrameMidY + 50 + yOffset + 50); AddChild(sprite); }); if (completed) { completeOffset -= 50; } else { incompleteOffset -= 50; } } }); }
public static SKLabelNode DropShadowOnLabel(SKLabelNode frontLabel) { SKLabelNode myLabelBackground = (SKLabelNode)frontLabel.Copy(); myLabelBackground.UserInteractionEnabled = false; myLabelBackground.FontColor = AppKit.NSColor.Black; myLabelBackground.Position = new CGPoint(2 + frontLabel.Position.X, -2 + frontLabel.Position.Y); myLabelBackground.ZPosition = frontLabel.ZPosition - 1; frontLabel.Parent.AddChild(myLabelBackground); return(myLabelBackground); }
public override void DidMoveToView(SKView view) { // Setup your scene here var myLabel = SKLabelNode.FromFont("Trebuchet MS"); myLabel.Text = "Starting.."; myLabel.FontSize = 44; myLabel.Position = new CGPoint(Frame.GetMidX(), Frame.GetMidY()); AddChild(myLabel); }
public override void DidMoveToView(SKView view) { // Setup your scene here var myLabel = SKLabelNode.FromFont("Chalkduster"); myLabel.Text = "Hello, World!"; myLabel.FontSize = 65; myLabel.Position = new CGPoint(Frame.GetMidX(), Frame.GetMidY()); AddChild(myLabel); }
public static SKLabelNode LabelWithText(string text, int textSize) { string fontName = "Optima-ExtraBlack"; SKLabelNode myLabel = new SKLabelNode(fontName); myLabel.Text = text; myLabel.FontSize = textSize; myLabel.FontColor = AppKit.NSColor.Yellow; return(myLabel); }
public override void DidMoveToView(SKView view) { // Setup your scene here var myLabel = new SKLabelNode("Chalkduster") { Text = "Hello, World!", FontSize = 65, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2) }; AddChild(myLabel); }
private SKLabelNode CreateHighscoreLabel() { var label = new SKLabelNode("Chalkduster") { ZPosition = 1, FontSize = 30, Position = new CGPoint(Frame.Width / 2, Frame.Height - 50) }; AddChild(label); return(label); }
public static SKLabelNode AddDescription(this SKNode self, string description, CGPoint position) { SKLabelNode label = new SKLabelNode("Helvetica") { Text = description, FontSize = 18, Position = position }; self.AddChild(label); return(label); }
public MainMenu (CGSize size) : base (size) { var title = new SKLabelNode ("GillSans-Bold") { Text = "Button Tapper", FontSize = 30f, Position = new CGPoint (FrameMidX, FrameMidY + 60) }; startButton = new SKLabelNode ("GillSans-Bold") { Text = "Start Game", FontSize = 18, FontColor = ButtonColor, Position = new CGPoint (FrameMidX, FrameMidY) }; gameCenterButton = new SKLabelNode ("GillSans-Bold") { Text = "Game Center", FontSize = 18, FontColor = ButtonColor, Position = new CGPoint (FrameMidX, FrameMidY - 60) }; gameStatsButton = new SKLabelNode ("GillSans-Bold") { Text = "Game Stats", FontSize = 18, FontColor = ButtonColor, Position = new CGPoint (FrameMidX, FrameMidY - 120) }; challengeFriendsButton = new SKLabelNode ("GillSans-Bold") { Text = "Challenge Friends", FontSize = 18, FontColor = ButtonColor, Position = new CGPoint (FrameMidX, FrameMidY - 180) }; playChallengeButton = new SKLabelNode ("GillSans-Bold") { Text = "Play Challenge", FontSize = 18, FontColor = ButtonColor, Position = new CGPoint (FrameMidX, FrameMidY - 240) }; SetupChallenge (); AddChild (title); AddChild (startButton); AddChild (gameCenterButton); AddChild (gameStatsButton); AddChild (challengeFriendsButton); AddChild (playChallengeButton); }
private SKLabelNode CreateInfoLabel() { var label = new SKLabelNode("Chalkduster") { Text = INFO_LABEL_TEXT, ZPosition = 1, FontSize = 30, Position = new CGPoint(Frame.Width / 2, Frame.Height - 200) }; AddChild(label); return(label); }
public MyScene(CGSize size) : base(size) { // Setup your scene here BackgroundColor = new UIColor (0.15f, 0.15f, 0.3f, 1.0f); var myLabel = new SKLabelNode ("Chalkduster") { Text = "Hello, World!", FontSize = 30, Position = new CGPoint (Frame.Width / 2, Frame.Height / 2) }; AddChild (myLabel); }
public MainGame (CGSize size) : base (size) { rand = new Random (); GameInfo.CurrentTaps = 0; gameTimer = NSTimer.CreateScheduledTimer (GameInfo.GameTimeInSeconds, async (t) => { gameTimer.Dispose(); gameTimer = null; await TimerDone (); }); tickTimer = NSTimer.CreateRepeatingScheduledTimer (1.0, async delegate { GameInfo.CurrentTicks --; if (GameInfo.CurrentTicks < 0) { GameInfo.CurrentTicks = 0; await TimerDone (); } }); button = new SKLabelNode ("GillSans-Bold") { Text = "Tap Me!", FontSize = 18, FontColor = ButtonColor, Position = new CGPoint (FrameMidX, FrameMidY) }; clicksLabel = new SKLabelNode ("AvenirNext-Bold") { Text = GameInfo.CurrentTaps.ToString (), FontSize = 45, Position = new CGPoint (FrameMidX, FrameMidY - 120) }; timerLabel = new SKLabelNode ("HelveticaNeue-CondensedBlack") { Text = GameInfo.CurrentTicks.ToString (), FontSize = 45, Position = new CGPoint (FrameMidX, FrameMidY + 120) }; AddChild (button); AddChild (clicksLabel); AddChild (timerLabel); }
public MyScene(SizeF size) : base(size) { lua.LoadCLRPackage (); lua.DoString ("import ('SpriteLua') import ('System')"); Player.MainScene = this; // Setup your scene here BackgroundColor = new UIColor (0.15f, 0.15f, 0.3f, 1.0f); var myLabel = new SKLabelNode ("Chalkduster") { Text = "NLua!", FontSize = 30, }; myLabel.Position = new PointF (Frame.X + Frame.Width / 2, Frame.Y + Frame.Height / 2); AddChild (myLabel); }
public StatsScreen (SizeF size) : base (size) { BackgroundColor = UIColor.FromRGBA (0.15f, 0.15f, 0.3f, 1f); var title = new SKLabelNode ("GillSans-Bold") { Text = "Stats", FontSize = 30, Position = new PointF (FrameMidX, FrameMidY + 60) }; leaderboardsButton = new SKLabelNode ("GillSans-Bold") { Text = "Leaderboards", FontSize = 18, FontColor = ButtonColor, Position = new PointF (FrameMidX, FrameMidY) }; achievementsButton = new SKLabelNode ("GillSans-Bold") { Text = "Achievements", FontSize = 18, FontColor = ButtonColor, Position = new PointF (FrameMidX, FrameMidY - 60) }; backButton = new SKLabelNode ("GillSans-Bold") { Text = "Back", FontSize = 18, FontColor = ButtonColor, Position = new PointF (FrameMidX, FrameMidY - 200) }; AddChild (title); AddChild (leaderboardsButton); AddChild (achievementsButton); AddChild (backButton); }
public void ProcessControllerAction(TVControllerAction item) { if (map.IsGameOver && item == TVControllerAction.Flag) item = TVControllerAction.Tap; switch (item) { case TVControllerAction.Left: CurrentX--; if (CurrentX < 0) CurrentX = 0; break; case TVControllerAction.Right: CurrentX++; if (CurrentX >= map.MapColumns) CurrentX = map.MapColumns - 1; break; case TVControllerAction.Up: CurrentY--; if (CurrentY < 0) CurrentY = 0; break; case TVControllerAction.Down: CurrentY++; if (CurrentY >= map.MapRows) CurrentY = map.MapRows - 1; break; case TVControllerAction.Flag: var flagResults = map.FlagSpot (CurrentX, CurrentY); flagResults.AffectedSpots.ForEach (RedisplaySpot); if (flagResults.GameReset) { DisplayMap (); } MoveCurrentPositionToTop (); UpdateLevelDisplay (); break; case TVControllerAction.Tap: var actionDetails = map.ClickOnSpot (CurrentX, CurrentY); actionDetails.AffectedSpots.ForEach (RedisplaySpot); if (actionDetails.GameOver) { RedisplaySpot (new Spot (CurrentX, CurrentY)); // Blow up all the spots MakeExplosionAtPoint (new Spot (CurrentX, CurrentY)); var allMines = map.GetAllMinesNear (new Spot (CurrentX, CurrentY)); allMines.ForEach (MakeExplosionAtPoint); gameOverNode = new SKLabelNode (displayFontGameOver) { Text = "Game Over", Position = new CGPoint(Scene.Frame.GetMidX(), Scene.Frame. GetMidY()), FontColor = UIColor.Blue, FontSize = displayFontSizeGameOver, VerticalAlignmentMode = SKLabelVerticalAlignmentMode.Center, HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Center }; float miniBuffer = 3f; gameOverNode2 = new SKLabelNode (displayFontGameOver) { Text = "Game Over", Position = new CGPoint(gameOverNode.Position.X + miniBuffer, gameOverNode.Position.Y - miniBuffer), FontColor = UIColor.FromRGBA(0.0f, 0f, 0f, 0.25f), FontSize = displayFontSizeGameOver, VerticalAlignmentMode = SKLabelVerticalAlignmentMode.Center, HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Center }; AddChild (gameOverNode2); AddChild (gameOverNode); gameOverNode.RunAction (SKAction.RotateByAngle ( (nfloat)(Math.PI / 180) * 720, 1.0)); gameOverNode2.RunAction (SKAction.RotateByAngle ( (nfloat)(Math.PI / 180) * 720, 1.0)); currentSpot.RunAction(SKAction.RemoveFromParent()); currentSpot = null; } if (actionDetails.GameReset) { DisplayMap (); } MoveCurrentPositionToTop (); UpdateLevelDisplay (); break; } UpdateCurrentSpot(); currentSpot.RunAction (SKAction.MoveTo ( GetCellPosition (CurrentX, CurrentY), 0.25 )); }
public static SKLabelNode LabelWithText (string text, int textSize) { string fontName = "Optima-ExtraBlack"; SKLabelNode myLabel = new SKLabelNode (fontName); myLabel.Text = text; myLabel.FontSize = textSize; myLabel.FontColor = AppKit.NSColor.Yellow; return myLabel; }
void DisplayMap() { foreach (var item in spritesForLocation) { item.Value.RunAction (SKAction.RemoveFromParent ()); } spritesForLocation.Clear (); gameOverNode?.RunAction (SKAction.RemoveFromParent ()); gameOverNode = null; nfloat topTextSpace = 80f; cellWidth = Scene.Frame.Width / map.MapColumns; cellHeight = (Scene.Frame.Height - topTextSpace) / map.MapRows; for (var y = 0; y < map.MapRows; y++) for (var x = 0; x < map.MapColumns; x++) { // Add the item in the appropriate position var cell = map[x, y]; SKSpriteNode sprite = GetSpriteForCell (cell); AddChild (sprite); spritesForLocation [map.LocationForXY (x, y)] = sprite; } CurrentX = AllLevels.CurrentLevel.StartX; CurrentY = AllLevels.CurrentLevel.StartY; UpdateCurrentSpot (); // Add the text information (Level <number>: <name>) if (levelNumber != null) { levelNumber.RunAction (SKAction.RemoveFromParent ()); levelNumber = null; } if (levelName != null) { levelName.RunAction (SKAction.RemoveFromParent ()); levelName = null; } levelName = new SKLabelNode (displayFont) { Text = map.CurrentLevel.LevelName, Position = new CGPoint(GetCellPosition (0, -1).X, Scene.Frame.Height - 33f), FontColor = UIColor.Black, FontSize = displayFontSize, HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Left }; AddChild (levelName); levelNumber = new SKLabelNode (displayFont) { Text = map.CurrentLevel.LevelName, Position = new CGPoint(GetCellPosition (map.MapColumns, -1).X / 2, levelName.Position.Y), FontColor = UIColor.Black, FontSize = displayFontSize, HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Left }; AddChild (levelNumber); UpdateLevelDisplay (); }
public LeaderboardSetsScreen (CGSize size) : base (size) { leaderboardSetButtons = new List<SKLabelNode> (); SKLabelNode title = new SKLabelNode ("GillSans-Bold") { Text = "Leaderboards Sets", FontSize = 30, Position = new CGPoint (FrameMidX, FrameMidY + 190) }; backButton = new SKLabelNode ("GillSans-Bold") { Text = "Back", FontSize = 18, FontColor = ButtonColor, Position = new CGPoint (FrameMidX, FrameMidY - 200) }; if (GKLocalPlayer.LocalPlayer.Authenticated) GKLeaderboardSet.LoadLeaderboardSets (LoadLeaderboardSets); AddChild (title); AddChild (backButton); }
void LoadLeaderboard (GKLeaderboard[] leaderboards, NSError error) { this.leaderboards = leaderboards; int offset = 0; foreach (var leaderboard in leaderboards) { SKLabelNode leaderboardButton = new SKLabelNode ("GillSans-Bold") { Text = leaderboard.Title, FontSize = 18, Position = new PointF (FrameMidX, FrameMidY + 125 - offset) }; offset += 50; AddChild (leaderboardButton); leaderboardButtons.Add (leaderboardButton); } }
private void CreateLabel() { if (Text != "") { checkLabel = new SKLabelNode (); checkLabel.FontName = "Roboto"; checkLabel.FontColor = UIColor.White; checkLabel.FontSize = 25; checkLabel.Position = new CGPoint (75, 20); checkLabel.ZPosition = this.Z + 1; checkLabel.Text = this.Text; checkLabel.HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Left; checkLabel.Name = this.Name + "Label"; this.Sprite.AddChild (checkLabel); } }
// Конструктор по имени public BeloteButton(string Name) : base(Name) { ButtonLabel = null; enabled = true; }
void LoadAchievementInfo (GKAchievementDescription[] descriptions, NSError error) { if (descriptions == null) return; GKAchievement.LoadAchievements (delegate (GKAchievement[] achievements, NSError err) { int completeOffset = 0; int incompleteOffset = 0; foreach (var description in descriptions) { bool completed = false; foreach (var achievement in achievements) { if (description.Identifier == achievement.Identifier) completed |= achievement.Completed; } int xOffset = completed ? -75 : 75; int yOffset = completed ? completeOffset : incompleteOffset; var achievementLabel = new SKLabelNode ("GillSans-Bold") { Text = description.Title, FontSize = 10, Position = new PointF (FrameMidX + xOffset, FrameMidY + 50 + yOffset + 25) }; AddChild (achievementLabel); description.LoadImage (delegate (UIImage image, NSError imageError) { if (image == null) image = UIImage.FromFile ("Images/DefaultPlayerPhoto.png"); var sprite = SKSpriteNode.FromTexture (SKTexture.FromImage (image), new SizeF (32, 32)); sprite.Position = new PointF (FrameMidX + xOffset, FrameMidY + 50 + yOffset + 50); AddChild (sprite); }); if (completed) completeOffset -= 50; else incompleteOffset -= 50; } }); }
public void Setup () { nfloat w = Bounds.Width; nfloat h = Bounds.Height; if (w < h) { nfloat wTmp = w; w = h; h = wTmp; } // Setup the game overlays using SpriteKit SKScene skScene = SKScene.FromSize (new CGSize (w, h)); skScene.ScaleMode = SKSceneScaleMode.ResizeFill; overlayGroup = SKNode.Create (); skScene.AddChild (overlayGroup); overlayGroup.Position = new CGPoint (0f, h); // The Max icon SKSpriteNode sprite = SKSpriteNode.FromImageNamed ("Images/MaxIcon.png"); sprite.Position = new CGPoint (50f, -50f); overlayGroup.AddChild (sprite); sprite.XScale = sprite.YScale = 0.5f; for (int i = 0; i < 3; i++) { flowers [i] = SKSpriteNode.FromImageNamed ("Images/FlowerEmpty.png"); flowers [i].Position = new CGPoint (110f + i * 40f, -50f); flowers [i].XScale = flowers [i].YScale = 0.25f; overlayGroup.AddChild (flowers[i]); } // The peal icon and count. sprite = SKSpriteNode.FromImageNamed ("Images/ItemsPearl.png"); sprite.Position = new CGPoint (110f, -100f); sprite.XScale = sprite.YScale = 0.5f; overlayGroup.AddChild (sprite); pearlLabel = SKLabelNode.FromFont ("Chalkduster"); pearlLabel.Text = "x0"; pearlLabel.Position = new CGPoint (152f, -113f); overlayGroup.AddChild (pearlLabel); // The D-Pad sprite = SKSpriteNode.FromImageNamed ("Images/dpad.png"); sprite.Position = new CGPoint (100f, 100f); sprite.XScale = sprite.YScale = 0.5f; skScene.AddChild (sprite); padRect = new CGRect ( (sprite.Position.Y - DPAD_RADIUS) / w, 1f - (sprite.Position.Y + DPAD_RADIUS) / h, 2f * DPAD_RADIUS / w, 2f * DPAD_RADIUS / h ); // Assign the SpriteKit overlay to the SceneKit view. OverlayScene = skScene; // Setup the pinch gesture defaultFov = PointOfView.Camera.XFov; var pinch = new UIPinchGestureRecognizer { Delegate = this, CancelsTouchesInView = false }; pinch.AddTarget (() => PinchWithGestureRecognizer (pinch)); AddGestureRecognizer (pinch); }
void LoadLeaderboardSets (GKLeaderboardSet[] leaderboardSets, NSError error) { this.leaderboardSets = leaderboardSets; if (leaderboardSets == null) return; int offset = 0; foreach (var leaderboardSet in leaderboardSets) { var leaderboardSetButton = new SKLabelNode ("GillSans-Bold") { Text = leaderboardSet.Title, FontSize = 18, Position = new PointF (FrameMidX, FrameMidY + 125 - offset) }; offset += 50; AddChild (leaderboardSetButton); leaderboardSetButtons.Add (leaderboardSetButton); } }
void DisplayScore (GKScore score, int rank, GKPlayer player) { PointF[] podiumPositions = new PointF[] { new PointF (0, 100), new PointF (-84, 75), new PointF (84, 50) }; PointF currentPoint = podiumPositions [rank]; SKLabelNode scoreLabel = new SKLabelNode ("GillSans-Bold") { Text = score.FormattedValue, FontSize = 14, Position = new PointF (FrameMidX + currentPoint.X, FrameMidY + currentPoint.Y - 32) }; player.LoadPhoto (GKPhotoSize.Small, delegate (UIImage photo, NSError error) { if (photo == null) photo = UIImage.FromFile ("Images/DefaultPlayerPhoto.png"); var image = SKSpriteNode.FromTexture (SKTexture.FromImage (photo), new SizeF (32, 32)); image.Position = new PointF (FrameMidX + currentPoint.X, FrameMidY + currentPoint.Y + 16); AddChild (image); }); AddChild (scoreLabel); }
public LeaderboardScoresScreen (SizeF size) : base (size) { SKLabelNode title = new SKLabelNode ("GillSans-Bold") { Text = GameInfo.CurrentLeaderBoard.Title, FontSize = 14, Position = new PointF (FrameMidX, FrameMidY + 200) }; var podiumSprite = SKSpriteNode.FromTexture (SKTexture.FromImageNamed ("Images/Podium.png")); podiumSprite.Position = new PointF (FrameMidX, FrameMidY + 50); backButton = new SKLabelNode ("GillSans-Bold") { Text = "Back", FontSize = 18, FontColor = ButtonColor, Position = new PointF (FrameMidX, FrameMidY - 200) }; if (GKLocalPlayer.LocalPlayer.Authenticated) LoadLeaderboardScoresInfo (GameInfo.CurrentLeaderBoard); AddChild (title); AddChild (backButton); AddChild (podiumSprite); }
public void ShowLabel(string label) { if (Label == null) { Label = SKLabelNode.FromFont ("Myriad Set"); if (Label == null) Label = SKLabelNode.FromFont ("Avenir-Heavy"); Label.FontSize = 140; Label.Position = new CGPoint (0, 0); AddChild (Label); } else { if (label != null) Label.Position = new CGPoint (0, Size.Height * 0.25f); } if (label == null) { Label.RunAction (SKAction.FadeOutWithDuration (0.5)); } else { #if __IOS__ if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) Label.FontSize = label.Length > 10 ? 50 : 80; else #endif Label.FontSize = label.Length > 10 ? 100 : 140; Label.Text = label; Label.Alpha = 0.0f; Label.RunAction (SKAction.Sequence (new [] { SKAction.WaitForDuration (0.5), SKAction.FadeInWithDuration (0.5) })); } }
// Создание надписи на кнопке private void CreateButtonLabel() { if (Text != "") { ButtonLabel = new SKLabelNode (); ButtonLabel.FontName = FontName; ButtonLabel.FontColor = FontColor; ButtonLabel.FontSize = FontSize; ButtonLabel.Position = new CGPoint (this.Width / 2, (this.Height / 2) - (this.FontSize / 2)); ButtonLabel.ZPosition = this.Z + 1; ButtonLabel.Text = this.Text; ButtonLabel.HorizontalAlignmentMode = SKLabelHorizontalAlignmentMode.Center; ButtonLabel.Name = this.Name + "Label"; this.Sprite.AddChild (ButtonLabel); } }
// Конструирование компонента по заданным свойствам public override void ConstructControl() { base.ConstructControl (); Sprite = new SKLabelNode (); ((SKLabelNode)Sprite).FontName = FontName; ((SKLabelNode)Sprite).FontColor = FontColor; ((SKLabelNode)Sprite).FontSize = FontSize; ((SKLabelNode)Sprite).Position = new CGPoint (this.X, this.Y); ((SKLabelNode)Sprite).ZPosition = this.Z; ((SKLabelNode)Sprite).Text = this.Text; ((SKLabelNode)Sprite).HorizontalAlignmentMode = HorizontalAlignment; Sprite.Name = this.Name; }
public GameSetupMenu(CGSize size) : base(size) { SKLabelNode timeLabel = new SKLabelNode ("GillSans-Bold") { Text = "Time", FontSize = 24, Position = new CGPoint (FrameMidX, FrameMidY + 70) }; SKLabelNode time15Button = new SKLabelNode ("GillSans-Bold") { Text = "15", FontSize = 14, FontColor = UnselectedColor, Position = new CGPoint (FrameMidX - 40, FrameMidY + 40) }; SKLabelNode time30Button = new SKLabelNode ("GillSans-Bold") { Text = "30", FontSize = 14, FontColor = UnselectedColor, Position = new CGPoint (FrameMidX, FrameMidY + 40) }; SKLabelNode time45Button = new SKLabelNode ("GillSans-Bold") { Text = "45", FontSize = 14, FontColor = UnselectedColor, Position = new CGPoint (FrameMidX + 40, FrameMidY + 40) }; timeLabels = new SKLabelNode[] { time15Button, time30Button, time45Button }; SKLabelNode modeLabel = new SKLabelNode ("GillSans-Bold") { Text = "Mode", FontSize = 24, Position = new CGPoint (FrameMidX, FrameMidY) }; SKLabelNode modeEasyButton = new SKLabelNode ("GillSans-Bold") { Text = "Easy", FontSize = 14, FontColor = UnselectedColor, Position = new CGPoint (FrameMidX - 40, FrameMidY - 40) }; SKLabelNode modeHardButton = new SKLabelNode ("GillSans-Bold") { Text = "Hard", FontSize = 14, FontColor = UnselectedColor, Position = new CGPoint (FrameMidX + 40, FrameMidY - 40) }; modeLabels = new [] { modeEasyButton, modeHardButton }; startButton = new SKLabelNode ("GillSans-Bold") { Text = "Start!", FontSize = 30, FontColor = ButtonColor, Position = new CGPoint (FrameMidX, FrameMidY - 100) }; backButton = new SKLabelNode ("GillSans-Bold") { Text = "Back", FontSize = 18, FontColor = ButtonColor, Position = new CGPoint (FrameMidX, FrameMidY - 200) }; timeLabels [(int)GameInfo.GameTime].FontColor = SelectedColor; modeLabels [(int)GameInfo.GameMode].FontColor = SelectedColor; GameInfo.ResetGame (); AddChild (timeLabel); foreach (var button in timeLabels) AddChild (button); AddChild (modeLabel); foreach (var button in modeLabels) AddChild (button); AddChild (startButton); AddChild (backButton); }
public PostGameMenu (CGSize frameSize, IGameUIState gameStateDelegate) { GameStateDelegate = gameStateDelegate; nfloat menuHeight = frameSize.Height * 0.8f; var background = new SKSpriteNode (AppKit.NSColor.Black, new CGSize (frameSize.Width * 0.8f, menuHeight)); background.ZPosition = -1; background.Alpha = 0.5f; background.Position = new CGPoint (0, -0.2f * menuHeight); myLabel = InGameScene.LabelWithText ("Final Score", 65); myLabel.Position = new CGPoint (Frame.GetMidX (), Frame.GetMidY ()); Position = new CGPoint (frameSize.Width * 0.5f, frameSize.Height * 0.5f); UserInteractionEnabled = true; myLabel.UserInteractionEnabled = true; AddChild (myLabel); InGameScene.DropShadowOnLabel (myLabel); var bananaLocation = new CGPoint (frameSize.Width * -0.4f, Frame.GetMidY () * -0.4f); var coinLocation = new CGPoint (frameSize.Width * -0.4f, Frame.GetMidY () * -0.6f); var totalLocation = new CGPoint (frameSize.Width * -0.4f, Frame.GetMidY () * -0.8f); var bananaScoreLocation = new CGPoint (frameSize.Width * +0.4f, Frame.GetMidY () * -0.4f); var coinScoreLocation = new CGPoint (frameSize.Width * +0.4f, Frame.GetMidY () * -0.6f); var totalScoreLocation = new CGPoint (frameSize.Width * +0.4f, Frame.GetMidY () * -0.8f); bananaText = (SKLabelNode)myLabel.Copy (); bananaText.Text = "Bananas"; bananaText.FontSize = 0.1f * menuHeight; bananaText.Scale = 0.8f; bananaLocation.X += bananaText.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f; bananaText.Position = new CGPoint (bananaLocation.X, -2000); AddChild (bananaText); InGameScene.DropShadowOnLabel (bananaText); bananaScore = (SKLabelNode)bananaText.Copy (); bananaScore.Text = "000"; bananaScoreLocation.X -= bananaScore.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f; bananaScore.Position = new CGPoint (bananaScoreLocation.X, -2000); AddChild (bananaScore); coinText = (SKLabelNode)bananaText.Copy (); coinText.Text = "Large Bananas"; coinLocation.X += coinText.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f; coinText.Position = new CGPoint (coinLocation.X, -2000f); AddChild (coinText); InGameScene.DropShadowOnLabel (coinText); coinScore = (SKLabelNode)coinText.Copy (); coinScore.Text = "000"; coinScoreLocation.X -= coinScore.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f; coinScore.Position = new CGPoint (coinScoreLocation.X, -2000f); AddChild (coinScore); totalText = (SKLabelNode)bananaText.Copy (); totalText.Text = "Total"; totalLocation.X += totalText.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f; totalText.Position = new CGPoint (totalLocation.X, -2000f); AddChild (totalText); InGameScene.DropShadowOnLabel (totalText); totalScore = (SKLabelNode)totalText.Copy (); totalScore.Text = "000"; totalScoreLocation.X -= totalScore.CalculateAccumulatedFrame ().Width * 0.5f + frameSize.Width * 0.1f; totalScore.Position = new CGPoint (totalScoreLocation.X, -2000f); AddChild (totalScore); SKAction flyup = SKAction.MoveTo (new CGPoint (frameSize.Width * 0.5f, frameSize.Height - 100), 0.25); flyup.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupBananas = SKAction.MoveTo (bananaLocation, 0.25); flyupBananas.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupBananasScore = SKAction.MoveTo (bananaScoreLocation, 0.25f); flyupBananasScore.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupCoins = SKAction.MoveTo (coinLocation, 0.25); flyupCoins.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupCoinsScore = SKAction.MoveTo (coinScoreLocation, 0.25); flyupCoinsScore.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupTotal = SKAction.MoveTo (totalLocation, 0.25); flyupTotal.TimingMode = SKActionTimingMode.EaseInEaseOut; SKAction flyupTotalScore = SKAction.MoveTo (totalScoreLocation, 0.25); flyupTotalScore.TimingMode = SKActionTimingMode.EaseInEaseOut; int bananasCollected = gameStateDelegate.BananasCollected; int coinsCollected = gameStateDelegate.CoinsCollected; int totalCollected = bananasCollected + (coinsCollected * 100); SKAction countUpBananas = SKAction.CustomActionWithDuration (bananasCollected / 100f, ((node, elapsedTime) => { if (bananasCollected > 0) { SKLabelNode label = (SKLabelNode)node; nint total = (nint)(elapsedTime / (bananasCollected / 100.0f) * bananasCollected); label.Text = total.ToString (); if (total % 10 == 0) GameSimulation.Sim.PlaySound ("deposit.caf"); } })); SKAction countUpCoins = SKAction.CustomActionWithDuration (coinsCollected / 100f, ((node, elapsedTime) => { if (coinsCollected > 0) { SKLabelNode label = (SKLabelNode)node; nint total = (nint)((elapsedTime / (coinsCollected / 100.0f)) * coinsCollected); label.Text = total.ToString (); if (total % 10 == 0) GameSimulation.Sim.PlaySound ("deposit.caf"); } })); SKAction countUpTotal = SKAction.CustomActionWithDuration (totalCollected / 500.0f, ((node, elapsedTime) => { if (totalCollected > 0) { SKLabelNode label = (SKLabelNode)node; nint total = (nint)((elapsedTime / (totalCollected / 500.0f)) * totalCollected); label.Text = total.ToString (); if (total % 25 == 0) GameSimulation.Sim.PlaySound ("deposit.caf"); } })); RunAction (flyup, () => { bananaText.RunAction (flyupBananas); bananaScore.RunAction (flyupBananasScore, () => { bananaScore.RunAction (countUpBananas, () => { bananaScore.Text = bananasCollected.ToString (); coinText.RunAction (flyupCoins); coinScore.RunAction (flyupCoinsScore, () => { coinScore.RunAction (countUpCoins, () => { coinScore.Text = coinsCollected.ToString (); totalText.RunAction (flyupTotal); totalScore.RunAction (flyupTotalScore, () => { totalScore.RunAction (countUpTotal, () => { totalScore.Text = totalCollected.ToString (); }); }); }); }); }); }); }); }
public MyScene(CGSize size) : base(size) { // Setup your scene here BackgroundColor = new UIColor(0.15f, 0.15f, 0.3f, 1.0f); var myLabel = new SKLabelNode("Chalkduster") { Text = "Hello, World!", FontSize = 30, Position = new CGPoint(Frame.Width / 2, Frame.Height / 2) }; AddChild(myLabel); CeilingNode = new SKSpriteNode { Color = UIColor.Orange, Size = new CGSize(Frame.Size.Width, 50), Position = new CGPoint(Frame.GetMaxX() / 2, Frame.GetMaxY() - 20), }; CeilingNode.PhysicsBody = SKPhysicsBody.CreateRectangularBody(CeilingNode.Size); CeilingNode.PhysicsBody.Dynamic = false; AddChild(CeilingNode); FloorNode = new SKSpriteNode { Color = UIColor.Orange, Size = new CGSize(Frame.Size.Width, 50), Position = new CGPoint(Frame.GetMaxX() / 2, 20), }; FloorNode.PhysicsBody = SKPhysicsBody.CreateRectangularBody(FloorNode.Size); FloorNode.PhysicsBody.Dynamic = false; AddChild(FloorNode); SpaceShip = new SKSpriteNode("Spaceship") { Position = new CGPoint(Frame.X + 100, Frame.GetMidY()), XScale = 0.4f, YScale = 0.4f, }; SpaceShip.PhysicsBody = SKPhysicsBody.CreateRectangularBody(SpaceShip.Size); AddChild(SpaceShip); var timer = new Timer() { Enabled = true, AutoReset = true, Interval = 300 }; timer.Elapsed += (sender, args) => { var wall1 = new Wall(UIColor.Blue, new CGSize(50, Frame.Height - 100)) { Position = new CGPoint(Frame.GetMaxX(), Frame.GetMidY()) }; wall1.PhysicsBody = SKPhysicsBody.CreateRectangularBody(wall1.Size); AddChild(wall1); this.Walls.Add(wall1); }; }
public LeaderboardsScreen (SizeF size) : base (size) { leaderboardButtons = new List<SKLabelNode> (); var title = new SKLabelNode ("GillSans-Bold") { Text = "Leaderboards", FontSize = 30, Position = new PointF (FrameMidX, FrameMidY + 200) }; backButton = new SKLabelNode ("GillSans-Bold") { Text = "Back", FontSize = 18, FontColor = ButtonColor, Position = new PointF (FrameMidX, FrameMidY - 200) }; if (GKLocalPlayer.LocalPlayer.Authenticated) GameInfo.CurrentSet.LoadLeaderboards (LoadLeaderboard); AddChild (title); AddChild (backButton); }