public void PlaySound(string soundFileName) { if (string.IsNullOrEmpty(soundFileName)) { return; } var path = string.Format("Sounds/{0}", soundFileName); GameUIScene.RunAction(SKAction.PlaySoundFileNamed(path, false)); }
public void DidBeginContact(MonoTouch.SpriteKit.SKPhysicsContact contact) { SKPhysicsBody headBody; SKPhysicsBody otherBody; if (contact.BodyA.CategoryBitMask == (uint)Categories.Head) { headBody = contact.BodyA; otherBody = contact.BodyB; } else { headBody = contact.BodyB; otherBody = contact.BodyA; } switch (otherBody.CategoryBitMask) { case (uint)Categories.Food: if (((int)headBody.Node.Position.X != (int)otherBody.Node.Position.X) || ((int)headBody.Node.Position.Y != (int)otherBody.Node.Position.Y)) { return; } RunAction(SKAction.Sequence(new [] { SKAction.PlaySoundFileNamed("Bite.mp3", false), SKAction.PlaySoundFileNamed("Swallow.mp3", false), })); score += 10; lblScore.Text = score.ToString() + " Points"; Food food = (Food)otherBody.Node; food.RunAction(SKAction.RemoveFromParent()); addBody = true; break; case (uint)Categories.Body: break; case (uint)Categories.Tail: break; default: break; } }
public void PlayMusic(string soundFileName) { if (soundFileName == null) { return; } if (GameUIScene.GetActionForKey(soundFileName) != null) { return; } string path = string.Format("Sounds/{0}", soundFileName); SKAction repeatAction = SKAction.RepeatActionForever(SKAction.PlaySoundFileNamed(path, true)); GameUIScene.RunAction(repeatAction, soundFileName); }
public override void TouchesBegan(NSSet touches, UIEvent evt) { var touch = (UITouch)touches.AnyObject; SKScene scene = OverlayScene; CGPoint p = touch.LocationInView(this); p = scene.ConvertPointFromView(p); SKNode node = scene.GetNodeAtPoint(p); if (node.Name == "camera") { node.RunAction(SKAction.PlaySoundFileNamed(ResourceManager.GetResourcePath("click.caf"), false)); ChangePointOfView(); return; } NSSet allTouches = evt.AllTouches; TouchesCount = (int)allTouches.Count; }
public void DidBeginContact(SKPhysicsContact contact) { inprogress = false; Console.WriteLine("We Collided!"); gameended = true; void gameOver() { var textures = Enumerable.Range(1, 4).Select( (i) => SKTexture.FromImageNamed(String.Format("Death-{0}", i))).ToArray(); deathSpin = SKAction.RepeatAction(SKAction.AnimateWithTextures(textures, .1), 4); var shrink = SKAction.ScaleTo(0f, 2f); var death = SKAction.Sequence(deathSpin, shrink); playerObject.RunAction(death); var playDeath = SKAction.PlaySoundFileNamed("playerDeath", false); playerDied.RunAction(playDeath); gameSong.RunAction(SKAction.CreateStop()); } void animateOver() { var grow = SKAction.ScaleTo(2.0f, 1.5); var shrink = SKAction.ScaleTo(.5f, 1.5); var animate = SKAction.RepeatActionForever(SKAction.Sequence(grow, shrink)); endGame.RunAction(animate); } playerObject.RemoveAllActions(); obstacle.RemoveAllActions(); sidewalk1.RemoveAllActions(); sidewalk2.RemoveAllActions(); sidewalk3.RemoveAllActions(); building1.RemoveAllActions(); building2.RemoveAllActions(); building3.RemoveAllActions(); building4.RemoveAllActions(); building5.RemoveAllActions(); building6.RemoveAllActions(); building7.RemoveAllActions(); building8.RemoveAllActions(); building9.RemoveAllActions(); building10.RemoveAllActions(); building11.RemoveAllActions(); building12.RemoveAllActions(); building13.RemoveAllActions(); building14.RemoveAllActions(); road1.RemoveAllActions(); road2.RemoveAllActions(); road3.RemoveAllActions(); road4.RemoveAllActions(); road5.RemoveAllActions(); road6.RemoveAllActions(); obstacle1.RemoveAllActions(); obstacle2.RemoveAllActions(); enemy.RemoveAllActions(); obstacle4.RemoveAllActions(); scores.Add(score); scores.Sort((a, b) => - 1 * a.CompareTo(b)); var sl = scores.Count; if (sl >= 10) { { sl = 10; } } var plist = NSUserDefaults.StandardUserDefaults; for (int i = 0; i < sl; i++) { { Console.WriteLine(scores[i]); plist.SetInt(scores[i], String.Format("Score-{0}", i)); } } score = 0; //unsubscribe obstacle objects at the end of the round timer.Elapsed -= sendobstacle; timer1.Elapsed -= sendobstacle1; timer2.Elapsed -= sendobstacle2; timer3.Elapsed -= sendobstacle3; timer4.Elapsed -= sendobstacle4; gameOver(); AddChild(endGame); animateOver(); }
public static void LoadSharedAssetsOnce() { sharedProjectileSoundAction = SKAction.PlaySoundFileNamed("magicmissile.caf", false); sharedDeathEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("Death"); sharedDamageEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("Damage"); }
public void playButtonPressedSound() { //var actionSound = SKAction.PlaySoundFileNamed ("Buttonpressed1.wav", true); this.RunAction(SKAction.PlaySoundFileNamed("./MyOutput.caf", false)); }