Sha256: 703209dfc36432ed526b2a5f2fc842bd0d0d8d8ecd4b08eb0150ffc13422bb85
Contents?: true
Size: 1009 Bytes
Versions: 2
Compression:
Stored size: 1009 Bytes
Contents
class MyScene < SKScene def initWithSize(size) super self.backgroundColor = SKColor.grayColor my_label = SKLabelNode.labelNodeWithFontNamed("Chalkduster") my_label.text = "Hello, World!" my_label.fontSize = 30 my_label.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame)) self.addChild(my_label) self end def mouseDown(theEvent) # Called when a mouse click occurs location = theEvent.locationInNode(self) # build a sprite for the scene sprite = SKSpriteNode.spriteNodeWithImageNamed("Spaceship") sprite.position = location sprite.scale = 0.3 # rotate the sprite a small amount action = SKAction.rotateByAngle(Math::PI, duration:0.5) # repeat this action forever sprite.runAction(SKAction.repeatActionForever(action)) # add the sprite to the scene self.addChild(sprite) end def update(current_time) # Called before each frame is rendered end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
motion-template-spritekit-0.4.0 | template/spritekit-osx/files/app/my_scene.rb |
motion-template-spritekit-0.3.0 | template/spritekit-osx/files/app/my_scene.rb |