issues
search
Aligamer12k
/
Gg
Kefl
1
stars
0
forks
source link
issues
Newest
Newest
Most commented
Recently updated
Oldest
Least commented
Least recently updated
import UIKit import SpriteKit class GameScene: SKScene { var player: SKSpriteNode! override func didMove(to view: SKView) { // Set up the player player = SKSpriteNode(color: .blue, size: CGSize(width: 50, height: 50)) player.position = CGPoint(x: size.width / 2, y: size.height / 2) addChild(player) } override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { // When the screen is touched, fire a bullet fireBullet() } func fireBullet() { let bullet = SKSpriteNode(color: .red, size: CGSize(width: 10, height: 10)) bullet.position = player.position addChild(bullet) let moveAction = SKAction.moveBy(x: 0, y: size.height, duration: 1.0) let removeAction = SKAction.removeFromParent() bullet.run(SKAction.sequence([moveAction, removeAction])) } override func update(_ currentTime: TimeInterval) { // Game update } }
#1
Aligamer12k
opened
1 year ago
1