public new static void LoadSharedAssetsOnce() { #if __IOS__ var whiteColor = UIColor.White; #else NSColor whiteColor = null; new NSObject().InvokeOnMainThread(() => { whiteColor = NSColor.White; }); #endif sharedProjectile = SKSpriteNode.FromColor(whiteColor, new CGSize(2, 24)); sharedProjectile.PhysicsBody = SKPhysicsBody.CreateCircularBody(ProjectileCollisionRadius); sharedProjectile.Name = @"Projectile"; sharedProjectile.PhysicsBody.CategoryBitMask = (uint)ColliderType.Projectile; sharedProjectile.PhysicsBody.CollisionBitMask = (uint)ColliderType.Wall; sharedProjectile.PhysicsBody.ContactTestBitMask = sharedProjectile.PhysicsBody.CollisionBitMask; sharedProjectileEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("ArcherProjectile"); sharedIdleAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Archer_Idle", "archer_idle_", DefaultNumberOfIdleFrames); sharedWalkAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Archer_Walk", "archer_walk_", DefaultNumberOfWalkFrames); sharedAttackAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Archer_Attack", "archer_attack_", ArcherAttackFrames); sharedGetHitAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Archer_GetHit", "archer_getHit_", ArcherGetHitFrames); sharedDeathAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Archer_Death", "archer_death_", ArcherDeathFrames); sharedDamageAction = SKAction.Sequence(new [] { SKAction.ColorizeWithColor(whiteColor, 10, 0), SKAction.WaitForDuration(0.75), SKAction.ColorizeWithColorBlendFactor(0, 0.25) }); }
void Explode() { // Create a bunch of explosion emitters and send them flying in all directions. Then remove the ship from the scene. for (int i = 0; i < numberOfChunks; i++) { SKEmitterNode explosion = NodeFactory.CreateExplosionNode(Scene, shipExplosionDuration); float angle = myRand(0, (float)Math.PI * 2); float speed = myRand(shipChunkMinimumSpeed, shipChunkMaximumSpeed); var x = myRand((float)Position.X - shipChunkDispersion, (float)Position.X + shipChunkDispersion); var y = myRand((float)Position.Y - shipChunkDispersion, (float)Position.Y + shipChunkDispersion); explosion.Position = new CGPoint(x, y); var body = SKPhysicsBody.CreateCircularBody(0.25f); body.CollisionBitMask = 0; body.ContactTestBitMask = 0; body.CategoryBitMask = 0; body.Velocity = new CGVector((float)Math.Cos(angle) * speed, (float)Math.Sin(angle) * speed); explosion.PhysicsBody = body; Scene.AddChild(explosion); } RunAction(SKAction.Sequence( SKAction.WaitForDuration(removeShipTime), SKAction.RemoveFromParent() )); }
public new static void LoadSharedAssetsOnce() { #if __IOS__ var whiteColor = UIColor.White; #else NSColor whiteColor = null; new NSObject().InvokeOnMainThread(() => { whiteColor = NSColor.White; }); #endif SKTextureAtlas atlas = SKTextureAtlas.FromName("Environment"); sharedProjectile = SKSpriteNode.FromTexture(atlas.TextureNamed("warrior_throw_hammer.png")); sharedProjectile.PhysicsBody = SKPhysicsBody.CreateCircularBody(ProjectileCollisionRadius); sharedProjectile.Name = "Projectile"; sharedProjectile.PhysicsBody.CategoryBitMask = (uint)ColliderType.Projectile; sharedProjectile.PhysicsBody.CollisionBitMask = (uint)ColliderType.Wall; sharedProjectile.PhysicsBody.ContactTestBitMask = sharedProjectile.PhysicsBody.CollisionBitMask; sharedProjectileEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("WarriorProjectile"); sharedIdleAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Warrior_Idle", "warrior_idle_", WarriorIdleFrames); sharedWalkAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Warrior_Walk", "warrior_walk_", DefaultNumberOfWalkFrames); sharedAttackAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Warrior_Attack", "warrior_attack_", WarriorThrowFrames); sharedGetHitAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Warrior_GetHit", "warrior_getHit_", WarriorGetHitFrames); sharedDeathAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Warrior_Death", "warrior_death_", WarriorDeathFrames); sharedDamageAction = SKAction.Sequence(new [] { SKAction.ColorizeWithColor(whiteColor, 10, 0), SKAction.WaitForDuration(0.5), SKAction.ColorizeWithColorBlendFactor(0, 0.25) }); }
// Show the congratulation screen. void ShowCongratulation() { var gNodes = gameNodes.Value; gNodes.Camera.UsesOrthographicProjection = false; sceneInterface.Scene.Background.Contents = UIColor.Black; gNodes.Confetti.Hidden = false; particleRemovalTimer?.Invalidate(); particleRemovalTimer = NSTimer.CreateScheduledTimer(30, RemoveParticles); gNodes.CongratulationsLabel.RemoveFromParent(); gNodes.CongratulationsLabel.Position = new CGPoint(ContentFrame.Width / 2, ContentFrame.Height / 2); gNodes.CongratulationsLabel.XScale = 0; gNodes.CongratulationsLabel.YScale = 0; gNodes.CongratulationsLabel.Alpha = 0; gNodes.CongratulationsLabel.RunAction(SKAction.Group(new SKAction [] { SKAction.FadeInWithDuration(0.25), SKAction.Sequence(new SKAction [] { SKAction.ScaleTo(0.7f, 0.25), SKAction.ScaleTo(0.8f, 0.2) }) })); sceneInterface.OverlayScene.AddChild(gNodes.CongratulationsLabel); }
private void SelectNodeForTouch(PointF touchLocation) { // get the node that is on the posiion touchLocation SKSpriteNode touchedNode = (SKSpriteNode)this.GetNodeAtPoint(touchLocation); // if this is a new node being touched then stop all previous animation and set it as the selected node. if (this.SelectedNode != touchedNode) { if (this.SelectedNode != null) { this.SelectedNode.RemoveAllActions(); this.SelectedNode.RunAction(SKAction.RotateToAngle(0.0f, 0.1)); } this.SelectedNode = touchedNode; // if the node we've touched is an animal node then make it wiggle y0! if (touchedNode.Name == ANIMAL_NODE_NAME) { SKAction sequence = SKAction.Sequence(new SKAction[] { SKAction.RotateByAngle(this.DegreeToRadian(-4.0f), 0.1), SKAction.RotateByAngle(0.0f, 0.1), SKAction.RotateByAngle(this.DegreeToRadian(4.0f), 0.1) }); this.SelectedNode.RunAction(SKAction.RepeatActionForever(sequence)); } } }
public void FireProjectile() { var projectile = (SKSpriteNode)Projectile.Copy(); projectile.Position = Position; projectile.ZRotation = ZRotation; var emitter = (SKEmitterNode)ProjectileEmitter.Copy(); emitter.TargetNode = CharacterScene.GetChildNode("world"); projectile.AddChild(emitter); CharacterScene.AddNode(projectile, WorldLayer.Character); var rot = ZRotation; float x = -(float)Math.Sin(rot) * HeroProjectileSpeed * HeroProjectileLifetime; float y = (float)Math.Cos(rot) * HeroProjectileSpeed * HeroProjectileLifetime; projectile.RunAction(SKAction.MoveBy(x, y, HeroProjectileLifetime)); projectile.RunAction(SKAction.Sequence(new [] { SKAction.WaitForDuration(HeroProjectileFadeOutTime), SKAction.FadeOutWithDuration(HeroProjectileLifetime - HeroProjectileFadeOutTime), SKAction.RemoveFromParent() })); projectile.RunAction(ProjectileSoundAction); var userData = new UserData { Player = Player }; projectile.UserData = (NSMutableDictionary)userData.Dictionary; }
public static void LoadSharedAssetsOnce() { #if __IOS__ var whiteColor = UIColor.White; #else NSColor whiteColor = null; new NSObject().InvokeOnMainThread(() => { whiteColor = NSColor.White; }); #endif SKTextureAtlas atlas = SKTextureAtlas.FromName("Environment"); sharedIdleAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Goblin_Idle", "goblin_idle_", DefaultNumberOfIdleFrames); sharedWalkAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Goblin_Walk", "goblin_walk_", DefaultNumberOfWalkFrames); sharedAttackAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Goblin_Attack", "goblin_attack_", GoblinAttackFrames); sharedGetHitAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Goblin_GetHit", "goblin_getHit_", GoblinGetHitFrames); sharedDeathAnimationFrames = GraphicsUtilities.LoadFramesFromAtlas("Goblin_Death", "goblin_death_", GoblinDeathFrames); sharedDamageEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("Damage"); sharedDeathSplort = SKSpriteNode.FromTexture(atlas.TextureNamed("minionSplort.png")); sharedDamageAction = SKAction.Sequence(new [] { SKAction.ColorizeWithColor(whiteColor, 1, 0), SKAction.WaitForDuration(0.75f), SKAction.ColorizeWithColorBlendFactor(0, 0.1) }); }
/// <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 void ShowEndScreen() { // Congratulation title var congratulationsNode = SKSpriteNode.FromImageNamed("Overlays/congratulations.png"); // Max image var characterNode = SKSpriteNode.FromImageNamed("Overlays/congratulations_pandaMax.png"); characterNode.Position = new CGPoint(0f, -220f); characterNode.AnchorPoint = new CGPoint(0.5f, 0f); this.congratulationsGroupNode = new SKNode(); this.congratulationsGroupNode.AddChild(characterNode); this.congratulationsGroupNode.AddChild(congratulationsNode); this.AddChild(this.congratulationsGroupNode); // Layout the overlay this.Layout2DOverlay(); // Animate congratulationsNode.Alpha = 0f; congratulationsNode.XScale = 0f; congratulationsNode.YScale = 0f; congratulationsNode.RunAction(SKAction.Group(new SKAction[] { SKAction.FadeInWithDuration(0.25), SKAction.Sequence(new SKAction[] { SKAction.ScaleTo(1.22f, 0.25), SKAction.ScaleTo(1f, 0.1) }) })); characterNode.Alpha = 0f; characterNode.XScale = 0f; characterNode.YScale = 0f; characterNode.RunAction(SKAction.Sequence(new SKAction[] { SKAction.WaitForDuration(0.5), SKAction.Group(new SKAction[] { SKAction.FadeInWithDuration(0.5), SKAction.Sequence(new SKAction[] { SKAction.ScaleTo(1.22f, 0.25), SKAction.ScaleTo(1f, 0.1) }) }) })); }
public void DidCollectKey() { this.collectedKeySprite.Texture = SKTexture.FromImageNamed("Overlays/key_full.png"); this.collectedKeySprite.RunAction(SKAction.Sequence(new SKAction[] { SKAction.WaitForDuration(0.5f), SKAction.ScaleBy(1.5f, 0.2f), SKAction.ScaleBy(1f / 1.5f, 0.2f) })); }
protected override void Move() { var action1 = SKAction.MoveBy(-50, 75, 0.5); var action2 = SKAction.MoveBy(-50, -75, 0.5); var seq = SKAction.Sequence(action1, action2); var finalAction = SKAction.RepeatActionForever(seq); Node.RunAction(finalAction); }
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); }
void ShowEndScreen() { gameIsComplete = true; // Add confettis SCNMatrix4 particlePosition = SCNMatrix4.CreateTranslation(0f, 8f, 0f); GameView.Scene.AddParticleSystem(confetti, particlePosition); // Congratulation title SKSpriteNode congrat = SKSpriteNode.FromImageNamed("Images/congratulations.png"); congrat.Position = new CGPoint(GameView.Bounds.Width / 2, GameView.Bounds.Height / 2); SKScene overlay = GameView.OverlayScene; congrat.XScale = congrat.YScale = 0; congrat.Alpha = 0; congrat.RunAction(SKAction.Group(new [] { SKAction.FadeInWithDuration(0.25), SKAction.Sequence(new [] { SKAction.ScaleTo(.55f, 0.25), SKAction.ScaleTo(.3f, 0.1), }) })); // Panda Image SKSpriteNode congratPanda = SKSpriteNode.FromImageNamed("Images/congratulations_pandaMax.png"); congratPanda.Position = new CGPoint(GameView.Bounds.Width / 2f, GameView.Bounds.Height / 2f - 90f); congratPanda.AnchorPoint = new CGPoint(.5f, 0f); congratPanda.XScale = congratPanda.YScale = 0f; congratPanda.Alpha = 0; congratPanda.RunAction(SKAction.Sequence(new [] { SKAction.WaitForDuration(.5f), SKAction.Sequence(new [] { SKAction.ScaleTo(.5f, 0.25), SKAction.ScaleTo(.4f, 0.1) }) })); overlay.AddChild(congratPanda); overlay.AddChild(congrat); // Stop music GameView.Scene.RootNode.RemoveAllAudioPlayers(); // Play the congrat sound. GameView.Scene.RootNode.AddAudioPlayer(SCNAudioPlayer.FromSource(victoryMusic)); // Animate the camera forever DispatchQueue.MainQueue.DispatchAfter(new DispatchTime(DispatchTime.Now, 1 * NanoSecondsPerSeond), () => { cameraYHandle.RunAction(SCNAction.RepeatActionForever(SCNAction.RotateBy(0f, -1f, 0f, 3.0))); cameraXHandle.RunAction(SCNAction.RotateTo(-(float)Math.PI / 4f, 0f, 0f, 5.0)); }); }
// Add Heartbeat Animation to parent node private void AddHeartbeat(double tempWait) { double wait = tempWait - 1; SKAction sleep = SKAction.WaitForDuration(wait); SKAction sizeUp = SKAction.ScaleTo(1.2f, 0.1f); SKAction sizeDown = SKAction.ScaleTo(0.9f, 0.1f); var sequence = SKAction.Sequence(sleep, sizeUp, sizeDown); RunAction(SKAction.RepeatActionForever(sequence)); }
public static void RunOneShotEmitter(SKEmitterNode emitter, float duration) { emitter.RunAction(SKAction.Sequence(new [] { SKAction.WaitForDuration(duration), SKAction.Run(() => { emitter.ParticleBirthRate = 0; }), SKAction.WaitForDuration(emitter.ParticleLifetime + emitter.ParticleLifetimeRange), SKAction.RemoveFromParent() })); }
public ExplosionNode(SKNode target) : base((template as NSObject).Copy().Handle) { TargetNode = target; NumParticlesToEmit = (uint)(defaultDuration * ParticleBirthRate); double totalTime = defaultDuration + ParticleLifetime + ParticleLifetimeRange / 2; RunAction(SKAction.Sequence( SKAction.WaitForDuration(totalTime), SKAction.RemoveFromParent() )); }
public void FollowPath(GKGraphNode[] path, Action <bool> completion) { if (path == null) { completion(false); return; } CharacterSpriteComponent comp = Entity.GetComponent <CharacterSpriteComponent> (); if (comp == null) { completion(false); return; } var dropFirst = path.Skip(1); Queue <SKAction> sequence = new Queue <SKAction> (); var sprite = comp.Sprite; sprite.RemoveActionForKey(WalkingKey); foreach (MapGraphNode node in dropFirst) { Entity centity = (Entity)Entity; CoreGraphics.CGPoint point = GameViewController.CurrentScene.CurrentMap.PositionToPoint(node.NodePosition, true); List <SKAction> subseq = new List <SKAction> (); subseq.Add(SKAction.Run(() => { comp.Direction = centity.Model.StartPosition.DirectionToPosition(node.NodePosition); centity.Model.StartPosition = node.NodePosition; sprite.ZPosition = GameViewController.CurrentScene.CurrentMap.ZLevelForPosition(node.NodePosition); comp.Walking = true; })); subseq.Add(SKAction.MoveTo(point, 0.8)); sequence.Enqueue(SKAction.Sequence(subseq.ToArray())); } sequence.Enqueue(SKAction.Run(() => comp.Walking = false)); if (completion != null) { sequence.Enqueue(SKAction.Run(() => completion(true))); } currentWalk = sequence; if (!comp.Walking) { RunNextStep(sprite); } }
void FireAnimationForState(AnimationState animationState, SKTexture[] frames, string key) { SKAction animAction = GetActionForKey(key); if (animAction != null || frames.Length < 1) { return; // we already have a running animation or there aren't any frames to animate } ActiveAnimationKey = key; RunAction(SKAction.Sequence(new [] { SKAction.AnimateWithTextures(frames, AnimationSpeed, true, false), SKAction.Run(() => AnimationHasCompleted(animationState)) }), key); }
SKAction GetResizeAction(SKTexture texture) { SKAction sequence = SKAction.Sequence( SKAction.WaitForDuration(1.0f), SKAction.ResizeTo(192.0f, 192.0f, 1.0f), SKAction.WaitForDuration(1.0f), SKAction.ResizeTo(128.0f, 192.0f, 1.0f), SKAction.WaitForDuration(1.0f), SKAction.ResizeTo(256.0f, 128.0f, 1.0f), SKAction.WaitForDuration(1.0f), SKAction.ResizeTo(texture.Size, 1.0f) ); return(SKAction.RepeatActionForever(sequence)); }
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; } }
void updateHUDFor(Player player, HUDState state, string message = null) { int playerIndex = players.IndexOf(player); SKSpriteNode avatar = hudAvatars [playerIndex]; avatar.RunAction(SKAction.Sequence(new [] { SKAction.FadeAlphaTo(1f, 1), SKAction.FadeAlphaTo(0.2f, 1), SKAction.FadeAlphaTo(1f, 1) })); SKLabelNode label = hudLabels [playerIndex]; float heartAlpha = 1f; switch (state) { case HUDState.Local: label.Text = "ME"; break; case HUDState.Connecting: heartAlpha = 0.25f; label.Text = message ?? "AVAILABLE"; break; case HUDState.Disconnected: avatar.Alpha = 0.5f; heartAlpha = 0.1f; label.Text = "NO PLAYER"; break; case HUDState.Connected: label.Text = message ?? "CONNECTED"; break; default: throw new NotImplementedException(); } for (int i = 0; i < player.LivesLeft; i++) { SKSpriteNode heart = hudLifeHeartArrays [playerIndex] [i]; heart.Alpha = heartAlpha; } }
public static SKEmitterNode CreateExplosionNode(SKNode target, double duration) { SKEmitterNode emitter = UnarchiveEmitterNode("explosion"); // Explosions always place their particles into the scene. emitter.TargetNode = target; // Stop spawning particles after enough have been spawned. emitter.NumParticlesToEmit = (nuint)(duration * emitter.ParticleBirthRate); // Calculate a time value that allows all the spawned particles to die. After this, the emitter node can be removed. double totalTime = duration + emitter.ParticleLifetime + emitter.ParticleLifetimeRange / 2; emitter.RunAction(SKAction.Sequence(SKAction.WaitForDuration(totalTime), SKAction.RemoveFromParent())); return(emitter); }
void RunNextStep(SKSpriteNode sprite) { if (currentWalk.Count == 0) { return; } List <SKAction> actions = new List <SKAction> (); // Pull the next step off the queue actions.Add(currentWalk.Dequeue()); actions.Add(SKAction.Run(() => { RunNextStep(sprite); })); sprite.RunAction(SKAction.Sequence(actions.ToArray())); }
public void EnableMove(double speedSec) { // Set size and speed SpeedLocal = speedSec; SizeLocal = 2f; // Define Line Node Movement SKAction scaleUp = SKAction.ScaleYTo(SizeLocal, SpeedLocal); SKAction scaleUpWaveUp = SKAction.ScaleYTo(SizeLocal + 0.3f, 0.1); SKAction scaleUpWaveDown = SKAction.ScaleYTo(SizeLocal, 0.1); SKAction scaleDown = SKAction.ScaleYTo(0.5f, SpeedLocal); SKAction scaleDownWaveDown = SKAction.ScaleYTo(0.5f - 0.3f, 0.1); SKAction scaleDownWaveUp = SKAction.ScaleYTo(0.5f, 0.1); SKAction scaleSeq = SKAction.Sequence(scaleUp, scaleUpWaveUp, scaleUpWaveDown, scaleDown, scaleDownWaveDown, scaleDownWaveUp); RunAction(SKAction.RepeatActionForever(scaleSeq)); }
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) })); } }
protected override void CreateSceneContents() { base.CreateSceneContents(); // no point in recomputing constant values each time var half_range = range / 2.0f; basex = (float)Scene.Frame.GetMidX() - half_range; basey = (float)Scene.Frame.GetMidY() - half_range; Scene.AddDescription("These textured sprite nodes are combined using an additive blend", new CGPoint(Scene.Frame.GetMidX(), 100)); Scene.RunAction(SKAction.RepeatActionForever(SKAction.Sequence( SKAction.Run(AddLight), SKAction.WaitForDuration(0.5f, 0.1f) ))); }
/// <summary> /// Анимация бонуса Бомба /// </summary> /// <param name="bomb">Бомба.</param> public void AnimateBomb(Gem bomb) { CGSize initialSize = new CGSize(gemCellWidth, gemCellHeight); CGSize newSize = new CGSize(gemCellWidth * (Properties.BombBlastRadius * 2 + 1), gemCellHeight * (Properties.BombBlastRadius * 2 + 1)); CGPoint initialPosition = GetPositionFromRowAndColumn(bomb.Row, bomb.Column); SKSpriteNode sprite = SKSpriteNode.FromImageNamed("bomb_blast"); sprite.Size = initialSize; sprite.Position = initialPosition; sprite.ZPosition = 110; SKAction resizeSprite = SKAction.ResizeTo(newSize, Properties.LineDestructionDuration / 1000f); gemLayer.AddChild(sprite); sprite.RunAction(SKAction.Sequence(resizeSprite, SKAction.RemoveFromParent())); }
/// <summary> /// Добававляем его спрайт на нод для камешка, с расчетом размера и позиции /// </summary> /// <param name="gem">Камешек которому добавляется спрайт.</param> private void AttachSpriteTo(Gem gem) { SKSpriteNode sprite; // Если разрушитель - открепляем старый спрайт на этом месте от слоя камешков if ((gem.IsALineDestroyer || gem.IsABomb) && Level.GemArray[gem.Row, gem.Column] != null) { sprite = Level.GemArray[gem.Row, gem.Column].Sprite; if (sprite != null && sprite.Parent != null) { sprite.RemoveFromParent(); } } // подготовка спрайта sprite = SKSpriteNode.FromImageNamed(gem.GetSpriteName()); sprite.Size = new CGSize(gemCellWidth, gemCellHeight); sprite.Position = GetPositionFromRowAndColumn(gem.Row, gem.Column); gemLayer.AddChild(sprite); gem.Sprite = sprite; // подготовка к анимации sprite.Alpha = 0; sprite.XScale = 0.5f; sprite.YScale = 0.5f; // Анимация появления камешка sprite.RunAction( SKAction.Sequence( SKAction.WaitForDuration(0.25, 0.5), SKAction.Group( SKAction.FadeInWithDuration(0.25), SKAction.ScaleTo(1.0f, 0.25) ) )); // если разрушитель - заменяем в массиве камешек if (gem.IsALineDestroyer || gem.IsABomb) { Level.GemArray[gem.Row, gem.Column] = gem; } }
public static void LoadSharedAssetsOnce() { #if __IOS__ var whiteColor = UIColor.White; #else NSColor whiteColor = null; new NSObject().InvokeOnMainThread(() => { whiteColor = NSColor.White; }); #endif SKTextureAtlas atlas = SKTextureAtlas.FromName("Environment"); SKEmitterNode fire = GraphicsUtilities.EmitterNodeWithEmitterNamed("CaveFire"); fire.ZPosition = 1; SKEmitterNode smoke = GraphicsUtilities.EmitterNodeWithEmitterNamed("CaveFireSmoke"); var sKNode = new SKNode(); sKNode.Add(fire); sKNode.Add(smoke); SKNode torch = sKNode; sharedCaveBase = SKSpriteNode.FromTexture(atlas.TextureNamed("cave_base.png")); // Add two torches either side of the entrance. torch.Position = new CGPoint(83, 83); sharedCaveBase.AddChild(torch); var torchB = (SKNode)torch.Copy(); torchB.Position = new CGPoint(-83, 83); sharedCaveBase.AddChild(torchB); sharedCaveTop = SKSpriteNode.FromTexture(atlas.TextureNamed("cave_top.png")); sharedDeathSplort = SKSpriteNode.FromTexture(atlas.TextureNamed("cave_destroyed.png")); sharedDamageEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("CaveDamage"); sharedDeathEmitter = GraphicsUtilities.EmitterNodeWithEmitterNamed("CaveDeathSmoke"); sharedDamageAction = SKAction.Sequence(new [] { SKAction.ColorizeWithColor(whiteColor, 1, 0), SKAction.WaitForDuration(0.25), SKAction.ColorizeWithColorBlendFactor(0, 0.1), }); }
protected override SKAction CreateShootAction() { Mat3 rotationMatrix = new Mat3(); rotationMatrix.SetRotation(-owner.CurrentRotation); Mat3 translationMatrix = new Mat3(); translationMatrix.SetTranslation(owner.Node.Scene.Size.Width, 0); Mat3 transformation = rotationMatrix * translationMatrix; var moveAction = SKAction.MoveBy( -(nfloat)transformation[6], -(nfloat)transformation[7], 2.5); var doneAction = SKAction.RemoveFromParent(); return(SKAction.Sequence(moveAction, doneAction)); }