It looks like x64 is required to use the SpriteKit framework.
Code: Select all
Enumeration
#SKBlendModeAlpha
#SKBlendModeAdd
#SKBlendModeSubtract
#SKBlendModeMultiply
#SKBlendModeMultiplyX2
#SKBlendModeScreen
#SKBlendModeReplace
EndEnumeration
; *** Import some things ***
ImportC "/System/Library/Frameworks/SpriteKit.framework/SpriteKit"
CGPathCreateMutable()
CGPathMoveToPoint(path, *m.CGAFFineTransform, x.CGFloat, y.CGFloat)
CGPathAddLineToPoint(path, *m.CGAFFineTransform, x.CGFloat, y.CGFloat)
CGPathAddCurveToPoint(path, *m.CGAFFineTransform, cp1x.CGFloat, cp1y.CGFloat, cp2x.CGFloat, cp2y.CGFloat, x.CGFloat, y.CGFloat)
CGPathAddQuadCurveToPoint(path, *m.CGAFFineTransform, cpx.CGFloat, cpy.CGFloat, x.CGFloat, y.CGFloat)
CGPathRelease(path)
EndImport
; *** Create View and Scene ***
Frame.NSRect\size\width = 640
Frame\size\height = 400
View = CocoaMessage(0, CocoaMessage(0, 0, "SKView alloc"), "initWithFrame:@", @Frame)
Scene = CocoaMessage(0, CocoaMessage(0, 0, "SKScene alloc"), "initWithSize:@", @Frame\size)
OpenWindow(0, 0, 0, Frame\size\width, Frame\size\height, "SpriteKit test (OS X 10.9)", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_Invisible)
CocoaMessage(0, CocoaMessage(0, WindowID(0), "contentView"), "addSubview:", View)
HideWindow(0, #False)
; *** Create sprite node ***
CreateImage(0, 64, 64, 32, #PB_Image_Transparent)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_AllChannels)
Ellipse(32, 32, 15, 30, RGBA(255, 128, 0, 255))
StopDrawing()
Texture = CocoaMessage(0, 0, "SKTexture textureWithImage:", ImageID(0))
SpriteNode1 = CocoaMessage(0, CocoaMessage(0, 0, "SKSpriteNode spriteNodeWithTexture:", Texture), "retain")
SpriteNode2 = CocoaMessage(0, CocoaMessage(0, 0, "SKSpriteNode spriteNodeWithTexture:", Texture), "retain")
; *** Run a repeated action for the sprite ***
Path = CGPathCreateMutable()
CGPathMoveToPoint(Path, #Null, 320, 200)
CGPathAddCurveToPoint(Path, #Null, 0, 0, 640, 0, 520, 100)
CGPathAddCurveToPoint(Path, #Null, 640, 0, 0, 0, 120, 100)
CGPathAddCurveToPoint(Path, #Null, 0, 0, 640, 0, 320, 200)
CGPathAddCurveToPoint(Path, #Null, 640, 0, 0, 0, 320, 200)
Duration.d = 10
Action1 = CocoaMessage(0, 0, "SKAction followPath:", Path, "asOffset:", #NO, "orientToPath:", #YES, "duration:@", @Duration)
RepeatedAction1 = CocoaMessage(0, 0, "SKAction repeatActionForever:", Action1)
CocoaMessage(0, SpriteNode1, "runAction:", RepeatedAction1)
CocoaMessage(0, SpriteNode1, "setBlendMode:", #SKBlendModeAdd)
Duration = 9
Action2 = CocoaMessage(0, 0, "SKAction followPath:", Path, "asOffset:", #NO, "orientToPath:", #YES, "duration:@", @Duration)
RepeatedAction2 = CocoaMessage(0, 0, "SKAction repeatActionForever:", Action2)
CocoaMessage(0, SpriteNode2, "runAction:", RepeatedAction2)
CocoaMessage(0, SpriteNode2, "setBlendMode:", #SKBlendModeAdd)
CGPathRelease(Path)
; *** Add the sprite to the scene and present the scene ***
CocoaMessage(0, Scene, "addChild:", SpriteNode1)
CocoaMessage(0, Scene, "addChild:", SpriteNode2)
CocoaMessage(0, View, "presentScene:", Scene)
; *** Main loop ***
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
