Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Updated version of source from https://neildanson.wordpress.com/2013/09/19/simple-spritekit-demo-in-f/
- namespace Demo
- open System
- open System.Drawing
- open Foundation
- open UIKit
- open SpriteKit
- open CoreGraphics
- [<Register ("ViewController")>]
- type ViewController (handle:IntPtr) =
- inherit UIViewController (handle)
- override x.DidReceiveMemoryWarning () =
- // Releases the view if it doesn't have a superview.
- base.DidReceiveMemoryWarning ()
- // Release any cached data, images, etc that aren't in use.
- override x.ViewDidLoad () =
- base.ViewDidLoad ()
- //Create and configure the view
- let skView = new SKView()
- let width = x.View.Bounds.Width * UIScreen.MainScreen.Scale
- let height = x.View.Bounds.Height * UIScreen.MainScreen.Scale
- skView.Bounds <- CGRect(nfloat 0.0, nfloat 0.0, width, height)
- skView.ShowsFPS <- true
- skView.ShowsNodeCount <- true
- x.View <- skView
- //Create and configure the screen
- let scene = new SKScene(skView.Bounds.Size)
- scene.BackgroundColor <- UIColor.Cyan
- scene.ScaleMode <- SKSceneScaleMode.AspectFill
- //Create a sprite
- let spriteNode = new SKSpriteNode "Spaceship"
- spriteNode.Position <- CGPoint(200.0,200.0)
- //Set a repeating 360 degree rotation
- let action = SKAction.RotateByAngle(nfloat Math.PI,1.0)
- let action = SKAction.RepeatActionForever action
- spriteNode.RunAction action
- //Add sprite to scene
- scene.AddChild spriteNode
- //Show scene
- skView.PresentScene scene
- override x.ShouldAutorotateToInterfaceOrientation (toInterfaceOrientation) =
- // Return true for supported orientations
- if UIDevice.CurrentDevice.UserInterfaceIdiom = UIUserInterfaceIdiom.Phone then
- toInterfaceOrientation <> UIInterfaceOrientation.PortraitUpsideDown
- else
- true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement