public void Atlas_MissingResource() { TestRuntime.AssertSystemVersion(PlatformName.iOS, 7, 0, throwIfOtherPlatform: false); TestRuntime.AssertSystemVersion(PlatformName.TvOS, 9, 0, throwIfOtherPlatform: false); TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 9, throwIfOtherPlatform: false); TestRuntime.AssertSystemVersion(PlatformName.WatchOS, 3, 0, throwIfOtherPlatform: false); using (var atlas = new SKTextureAtlas()) { // that returns a texture, calling 'MissingResource.png' (128 x 128) using (var texture = atlas.TextureNamed("ship")) { // this completionHandler is *NOT* optional -> crash if null SKTexture.PreloadTextures(new [] { texture }, CrashAvoider); // this completionHandler is *NOT* optional -> crash if null texture.Preload(CrashAvoider); Assert.That(texture.FilteringMode, Is.EqualTo(SKTextureFilteringMode.Linear), "FilteringMode"); #if !MONOMAC // FIXME: bug in iOS9 - it will randomly return 0,0 (but almost always on the first try) if (!TestRuntime.CheckSystemVersion(PlatformName.iOS, 9, 0, throwIfOtherPlatform: false)) { Assert.That(texture.Size, Is.EqualTo(new CGSize(128, 128)), "Size"); } #endif Assert.That(texture.TextureRect, Is.EqualTo(new CGRect(0, 0, 1, 1)), "TextureRect"); Assert.False(texture.UsesMipmaps, "UsesMipmaps"); } } }
private void CreateEmitterNode() { // Setup a intial Location var location = new CGPoint(); location.X = (((View.Frame.Width / 2))); location.Y = (((View.Frame.Height / 4))); // Define paricles and initial settings particleEmitterNode = new SKEmitterNode(); particleEmitterNode.Position = location; particleEmitterNode.NumParticlesToEmit = 0; particleEmitterNode.ZPosition = 2; particleEmitterNode.ParticleAlpha = 0.4f; particleEmitterNode.XAcceleration = 0; particleEmitterNode.YAcceleration = 1; particleEmitterNode.EmissionAngle = 100f; particleEmitterNode.TargetNode = this; particleEmitterNode.ParticleScale = 0.4f; particleEmitterNode.ParticleSpeedRange = 100f; particleEmitterNode.ParticleScaleRange = 0.5f; particleEmitterNode.ParticleScaleSpeed = -0.1f; particleEmitterNode.ParticleBirthRate = 500; particleEmitterNode.ParticlePositionRange = new CGVector(120f, 120f); particleEmitterNode.ParticleLifetimeRange = 10f; particleEmitterNode.ParticleRotationRange = 10f; particleEmitterNode.EmissionAngleRange = 200f; particleEmitterNode.ParticleTexture = SKTexture.FromImageNamed(("spark")); }
public void Atlas_MissingResource() { if (!TestRuntime.CheckSystemAndSDKVersion(7, 0)) { Assert.Ignore("Requires iOS7"); } using (var atlas = new SKTextureAtlas()) { // that returns a texture, calling 'MissingResource.png' (128 x 128) using (var texture = atlas.TextureNamed("ship")) { // this completionHandler is *NOT* optional -> crash if null SKTexture.PreloadTextures(new [] { texture }, CrashAvoider); // this completionHandler is *NOT* optional -> crash if null texture.Preload(CrashAvoider); Assert.That(texture.FilteringMode, Is.EqualTo(SKTextureFilteringMode.Linear), "FilteringMode"); // FIXME: bug in iOS9 - it will randomly return 0,0 (but almost always on the first try) if (!UIDevice.CurrentDevice.CheckSystemVersion(9, 0)) { Assert.That(texture.Size, Is.EqualTo(new SizeF(128, 128)), "Size"); } Assert.That(texture.TextureRect, Is.EqualTo(new RectangleF(0, 0, 1, 1)), "TextureRect"); Assert.False(texture.UsesMipmaps, "UsesMipmaps"); } } }
SKTexture[] LoadFrames(string baseImageName, int frameCount) { var frames = new SKTexture [frameCount]; for (int i = 1; i <= frameCount; i++) frames [i - 1] = SKTexture.FromImageNamed (baseImageName + i.ToString ("0000")); return frames; }
public MapNode(Map map) { this.map = map; Name = "Map"; UserInteractionEnabled = true; int idx = 0; atlas = SKTextureAtlas.FromName("TileImages"); foreach (var tid in map.TIDs) { Tile t = map.TIDToTile [tid]; CoreGraphics.CGPoint position = map.PositionToPoint(map.IndexToPosition(idx)); SKTexture tex = atlas.TextureNamed(t.ImageName); SKSpriteNode node = SKSpriteNode.FromTexture(tex); node.UserInteractionEnabled = false; node.Position = position; node.ZPosition = idx; node.AnchorPoint = new CoreGraphics.CGPoint(0.5, 0); AddChild(node); idx++; } var nc = NSNotificationCenter.DefaultCenter; nc.AddObserver((NSString)InventoryComponent.ItemCollectedNotification, HandleItemCollected); nc.AddObserver((NSString)InventoryComponent.ItemDroppedNotification, HandleItemDropped); }
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) })); }
public void SetPlayerDirection() { byte direction = 0; direction = GetDirection(); this.dir = direction; //all SIde E for now as the sprite pictures need to be redrawn switch (direction) { case 1: this.PlayerSpriteObject.Texture = SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("SideE", "png")); break; case 2: this.PlayerSpriteObject.Texture = SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("SideW", "png")); break; case 3: this.PlayerSpriteObject.Texture = SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("SideW", "png")); break; case 4: this.PlayerSpriteObject.Texture = SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("SideE", "png")); break; } }
/// <summary> /// Render the buttons. /// </summary> void RenderButtons() { var start_button = Button.CreateButtonAt( SKTexture.FromImageNamed(START_BUTTON_IMAGE), SKTexture.FromImageNamed(START_PRESSED_BUTTON_IMAGE), "start", new CGPoint(Frame.GetMidX(), Frame.GetMidY() * 1.25) ); var settings_button = Button.CreateButtonAt( SKTexture.FromImageNamed(SETTINGS_BUTTON_IMAGE), SKTexture.FromImageNamed(SETTINGS_PRESSED_BUTTON_IMAGE), "settings", new CGPoint(Frame.GetMidX(), Frame.GetMidY() * 0.75) ); var exit_button = Button.CreateButtonAt( SKTexture.FromImageNamed(EXIT_BUTTON_IMAGE), SKTexture.FromImageNamed(EXIT_PRESSED_BUTTON_IMAGE), "exit", new CGPoint(Frame.GetMidX(), Frame.GetMidY() * 0.25) ); AddChild(start_button); AddChild(settings_button); AddChild(exit_button); }
public Character(SKTexture texture, CGPoint position) : base(texture) { // standard sprite - there's no parallax UsesParallaxEffect = false; Initialize(position); }
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); }
public Character(SKTexture texture, CGPoint position) : base(texture) { // standard sprite - there's no parallax UsesParallaxEffect = false; Initialize (position); }
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); }
public static Button CreateButtonAt(SKTexture texture_passive, SKTexture texture_active, string name, CGPoint position) { return(new Button(texture_passive, texture_active, name) { Position = position }); }
public BasicScene(CGSize size) : base(size) { ScaleMode = SKSceneScaleMode.AspectFill; //BackgroundColor = UIColor.FromRGBA (0.15f, 0.15f, 0.3f, 1f); bgr = new SKSpriteNode(SKTexture.FromImageNamed("brickwall1")); bgr.Size = Size; bgr.Position = new CGPoint(Size.Width / 2, Size.Height / 2); AddChild(bgr); UnselectedColor = UIColor.FromRGBA(0f, 0.5f, 0.5f, 1f); SelectedColor = UIColor.FromRGBA(0.5f, 1f, 0.99f, 1f); ButtonColor = UIColor.FromRGBA(1f, 1f, 0f, 1f); InfoColor = UIColor.FromRGBA(1f, 1f, 1f, 1f); FrameMidX = (float)Frame.GetMidX(); FrameMidY = (float)Frame.GetMidY(); transition = SKTransition.MoveInWithDirection(SKTransitionDirection.Right, 0.3); }
public BeloteCheckBox(string Name) : base(Name) { isCheck = false; CheckedTexture = SKTexture.FromImageNamed ("Textures/checkon.png"); UncheckedTexture = SKTexture.FromImageNamed ("Textures/checkoff.png"); this.Height = 62; }
// definition of player walking animation void animatePlayer() { var textures = Enumerable.Range(1, 4).Select( (i) => SKTexture.FromImageNamed(String.Format("Stumbler-{0}", i))).ToArray(); playerAnimate = SKAction.RepeatActionForever(SKAction.AnimateWithTextures(textures, 0.1)); playerObject.RunAction(playerAnimate); }
void animateobstacle4() { var textures = Enumerable.Range(1, 4).Select( (i) => SKTexture.FromImageNamed(String.Format("trash-{0}", i))).ToArray(); obstacleflame4 = SKAction.RepeatActionForever(SKAction.AnimateWithTextures(textures, 0.1)); obstacle4.RunAction(obstacleflame4); }
void animateEnemy() { var textures = Enumerable.Range(1, 4).Select( (i) => SKTexture.FromImageNamed(String.Format("walker-{0}", i))).ToArray(); enemyAnimate = SKAction.RepeatActionForever(SKAction.AnimateWithTextures(textures, 0.1)); enemy.RunAction(enemyAnimate); }
public Button(SKTexture texture_passive, SKTexture texture_active, string name) { _texture_passive = texture_passive; _texture_active = texture_active; Name = name; Texture = _texture_passive; Size = Texture.Size; }
public void addItemBackground(CGPoint itemPos) { var bottleCap = new SKSpriteNode(SKTexture.FromImageNamed("capitem1")); bottleCap.SetScale(0.4f); bottleCap.Position = itemPos; AddChild(bottleCap); }
public async void loadHater(UIImage hater) { // if (GameObj.finalImage != null) { // await System.Threading.Tasks.Task.Delay (2000); //RemoveAllChildren (); if (currentSelected == 1) { GameObj.finalImage = hater; _image1 = hater; _img1.RemoveFromParent(); _img1 = new SKSpriteNode(SKTexture.FromImage(hater)); //Frage (xy.hater));//(UIColor.DarkGray,new CGSize(200f,200f)); _img1.Size = new CGSize(100f, 100f); _img1.Position = new CGPoint(52, Size.Height / 1.3f); _pushPin.RemoveFromParent(); movePin(_img1.Position); // _img2.Position = new CGPoint (Size.Width / 2, Size.Height / 1.3f); AddChild(_img1); AddChild(_pushPin); } else if (currentSelected == 2) { _img2.RemoveFromParent(); _img2 = new SKSpriteNode(SKTexture.FromImage(hater)); //Frage (xy.hater));//(UIColor.DarkGray,new CGSize(200f,200f)); _img2.Size = new CGSize(100f, 100f); _img2.Position = new CGPoint(Size.Width / 2, Size.Height / 1.3f); AddChild(_img2); _image2 = hater; GameObj.finalImage = hater; _pushPin.RemoveFromParent(); movePin(_img2.Position); AddChild(_pushPin); } else if (currentSelected == 3) { _img3.RemoveFromParent(); _img3 = new SKSpriteNode(SKTexture.FromImage(hater)); //Frage (xy.hater));//(UIColor.DarkGray,new CGSize(200f,200f)); _img3.Size = new CGSize(100f, 100f); _img3.Position = new CGPoint(Size.Width - 52, Size.Height / 1.3f); AddChild(_img3); _image3 = hater; GameObj.finalImage = hater; _pushPin.RemoveFromParent(); movePin(_img3.Position); AddChild(_pushPin); } }
SKTexture[] TextureArrayFromAtlas(SKTextureAtlas atlas, string name, int row) { SKTexture[] textures = new SKTexture[8]; for (int i = 0; i < 8; i++) { textures[i] = atlas.TextureNamed(String.Format("{0}-{1}-{2}", name, row, i + 1)); } return(textures); }
public UtilityHelo() { this.MachineGun = new Bullets[50]; for (int i = 0; i < this.MachineGun.Length; i += 1) { this.MachineGun[i] = new Bullets(); this.MachineGun[i].Bullet.Texture = SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("BulletImage_small", "png")); } }
public ItemSpriteComponent(SKTexture texture, GKEntity entity) { Sprite = new EntityNode(); Sprite.Texture = texture; Sprite.Size = new CoreGraphics.CGSize(64f, 64f); Sprite.AnchorPoint = new CoreGraphics.CGPoint(0.5f, 0.0f); Sprite.UserInteractionEnabled = true; ((EntityNode)Sprite).Entity = entity; }
public PointNode(string name) { UIImage image = UIImage.FromBundle(name); Name = name; ZPosition = 12; Texture = SKTexture.FromImageNamed((name)); Size = image.Size; }
public bool DidCollectAFlower() { if (flowerCount < 3) { flowers [flowerCount].Texture = SKTexture.FromImageNamed("Images/FlowerFull.png"); } flowerCount++; return(flowerCount == 3); }
public void Texture() { using (var t = SKTexture.FromImageNamed("basn3p08.png")) using (var n = new SKSpriteNode(t)) { Assert.AreSame(n.Texture, t, "Texture-1"); n.Texture = null; Assert.IsNull(n.Texture, "Texture-2"); } }
public Bullets() { this.x_world = 0; this.y_world = 0; this.Bullet = new SKSpriteNode( SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("bullet", "png"))); this.isFired = false; this.damageCaused = 5; }
public override void TouchesBegan(NSSet touches, UIEvent evt) { // Called when a touch begins foreach (var touch in touches) { UITouch touchc = touches.AnyObject as UITouch; // Check click var locationc = touchc.LocationInNode(this); var checkX = touchc.LocationInView(View).X; var checkY = touchc.LocationInView(View).Y; // other coordinate system //var checkX = ((UITouch)touchc).LocationInNode(this).X; //var checkY = ((UITouch)touchc).LocationInNode(this).Y; // Get Sprite Node at current location var nodeAtLocation = GetNodeAtPoint(locationc); if (nodeAtLocation.Name == "cancelSpark") { ReleaseInfoText(); } else { if (nodeAtLocation.Name != "infoNode" && nodeAtLocation.Name != "infoLabel") { // If the info button is clicked change background if (nodeAtLocation.Name == "info" || nodeAtLocation.Name == "navSprite") { infoTouch = true; // Activate information background if (switchInfo == false) { //setInfoText(); container.Alpha = 1f; switchInfo = true; SKAction seqTextureInfo = SKAction.SetTexture(SKTexture.FromImageNamed(("inforeverse"))); infoSprite.RunAction((seqTextureInfo)); } // Deactivate information background else { container.Alpha = 0f; switchInfo = false; SKAction seqTextureInfoNormal = SKAction.SetTexture(SKTexture.FromImageNamed(("info"))); infoSprite.RunAction((seqTextureInfoNormal)); } } } } } }
public Tanks() { this.enemySprite = new SKSpriteNode( SKTexture.FromImageNamed(NSBundle.MainBundle.PathForResource("Tank", "png"))); this.Cannon = new Bullets[12]; this.MAXhSPEED = 25; this.MAXvSPEED = 25; this.pitch_cannon = 0; }
public virtual void Draw(GameScene scene) { if (SkNode == null) { SkNode = new SKSpriteNode(SKTexture.FromImageNamed("Ball"), UIColor.Clear, new CGSize(5, 5)); scene.AddChild(SkNode); } SkNode.RunAction(SKAction.MoveTo(new CGPoint(X - (Z / Math.Sqrt(2.0)), Y - (Z / Math.Sqrt(2.0))), 0.5)); }
SKTexture [] LoadFrames(string baseImageName, int frameCount) { var frames = new SKTexture [frameCount]; for (int i = 1; i <= frameCount; i++) { frames [i - 1] = SKTexture.FromImageNamed(baseImageName + i.ToString("0000")); } return(frames); }
public EnemySprite() { Texture = SKTexture.FromImageNamed(ENEMY_DUTY_IMAGE); Size = Texture.Size; PhysicsBody = SKPhysicsBody.CreateRectangularBody(Size); PhysicsBody.AllowsRotation = false; PhysicsBody.CategoryBitMask = CollisionCategory.Enemy; PhysicsBody.ContactTestBitMask = CollisionCategory.Hero | CollisionCategory.Spell | CollisionCategory.Platform; PhysicsBody.CollisionBitMask ^= CollisionCategory.Spell; }
protected HeroCharacter(SKTexture texture, CGPoint position, Player player) : base(texture, position) { Player = player; // Rotate by PI radians (180 degrees) so hero faces down rather than toward wall at start of game. ZRotation = (float)Math.PI; ZPosition = -0.25f; Name = "Hero"; }
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 static SKTexture[] LoadFramesFromAtlas(string atlasName, string baseFileName, int numberOfFrames) { var frames = new SKTexture[numberOfFrames]; SKTextureAtlas atlas = SKTextureAtlas.FromName (atlasName); for (int i = 0; i < numberOfFrames; i++) { int imageIndex = i + 1; // because starts from one string fileName = string.Format ("{0}{1:D4}.png", baseFileName, imageIndex); SKTexture texture = atlas.TextureNamed (fileName); frames [i] = texture; } return frames; }
public BeloteEdit(string Name, float Width, float Height, float X, float Y, SKTexture Texture, string Text, bool SecureText, BeloteFormAction onEndEditing) : this(Name) { this.Width = Width; this.Height = Height; this.X = X; this.Y = Y; this.Texture = Texture; this.Text = Text; this.SecureText = SecureText; this.OnEndEditing = onEndEditing; ConstructControl (); }
public BeloteCard(CardSuit Suit, CardType Type, bool IsHide, float X, float Y, BeloteFormAction onTouchStart, BeloteFormAction onTouchEnd) : this(Suit.ToString () + ((int)Type).ToString ()) { this.Suit = Suit; this.Type = Type; this.IsHide = IsHide; this.Width = 105; this.Height = 147; this.X = X; this.Y = Y; this.OnTouchEnd = onTouchEnd; this.OnTouchStart = onTouchStart; backTexture = SKTexture.FromImageNamed ("Textures/Cards/back.png"); cardTexture = SKTexture.FromImageNamed ("Textures/Cards/" + Helpers.SuitToString(Suit) + "/" + ((int)Type).ToString () + ".png"); ConstructControl (); }
public BeloteButton(string Name, float Width, float Height, float X, float Y, BeloteFormAction onTouchStart, BeloteFormAction onTouchEnd, SKTexture EnabledTexture, SKTexture DisabledTexture = null, string Text = "", float FontSize = 12, UIColor FontColor = null, string FontName = "Roboto") : this(Name) { this.Width = Width; this.Height = Height; this.X = X; this.Y = Y; this.OnTouchStart = onTouchStart; this.OnTouchEnd = onTouchEnd; this.EnabledTexture = EnabledTexture; this.DisabledTexture = DisabledTexture; buttonText = Text; this.FontName = FontName; this.FontSize = FontSize; if (FontColor != null) this.FontColor = FontColor; else this.FontColor = UIColor.White; ConstructControl (); }
public SpaceShip(SKTexture texture) : base(texture) { }
protected ParallaxSprite(SKTexture texture) : base(texture) { }
public SpaceShip(SKTexture texture, UIColor color, CGSize size) : base(texture, color, size) { }
protected EnemyCharacter(SKTexture texture, CGPoint position) : base(texture, position) { }
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); }