SpriteKit を用いて タモさん を神と崇める feat. Playground
6780 ワード
はじめに
- 前回の続きです
SpriteKit を用いて 田代まさしを左右に動かす feat. Playground
アニメ
- Preview.app で適当に作成した画像をループする
コード
タモさん.swift
//: Playground - noun: a place where people can play
import SpriteKit
import XCPlayground
struct Constants {
static let TamoriImages = ["tamori", "tamori1", "tamori2", "tamori3"]
}
let sceneWidth = 500
let sceneHeight = 500
internal var tamori: SKSpriteNode!
func repeatTamosan(scene: SKScene) -> Void {
var playerTexture = [SKTexture]()
for imageName in Constants.TamoriImages {
let texture = SKTexture(imageNamed: imageName)
texture.filteringMode = .Linear
playerTexture.append(texture)
}
let playerAnimation = SKAction.animateWithTextures(playerTexture, timePerFrame: 0.2)
let loopAnimation = SKAction.repeatAction(playerAnimation, count: 10)
tamori = SKSpriteNode(texture: playerTexture[0])
tamori.position = CGPoint(x: 250, y: 250)
tamori.runAction(loopAnimation)
scene.addChild(tamori)
}
let skView = SKView(frame: CGRect(x: 0, y: 0, width: sceneWidth, height: sceneWidth))
let skScene = SKScene(size: CGSize(width: sceneWidth, height: sceneHeight))
repeatTamosan(skScene)
skView.presentScene(skScene)
XCPShowView("Live SKView: Iitomo", view: skView)
Playground
- 今回は無しで...
Reference
タモさん.swift
//: Playground - noun: a place where people can play
import SpriteKit
import XCPlayground
struct Constants {
static let TamoriImages = ["tamori", "tamori1", "tamori2", "tamori3"]
}
let sceneWidth = 500
let sceneHeight = 500
internal var tamori: SKSpriteNode!
func repeatTamosan(scene: SKScene) -> Void {
var playerTexture = [SKTexture]()
for imageName in Constants.TamoriImages {
let texture = SKTexture(imageNamed: imageName)
texture.filteringMode = .Linear
playerTexture.append(texture)
}
let playerAnimation = SKAction.animateWithTextures(playerTexture, timePerFrame: 0.2)
let loopAnimation = SKAction.repeatAction(playerAnimation, count: 10)
tamori = SKSpriteNode(texture: playerTexture[0])
tamori.position = CGPoint(x: 250, y: 250)
tamori.runAction(loopAnimation)
scene.addChild(tamori)
}
let skView = SKView(frame: CGRect(x: 0, y: 0, width: sceneWidth, height: sceneWidth))
let skScene = SKScene(size: CGSize(width: sceneWidth, height: sceneHeight))
repeatTamosan(skScene)
skView.presentScene(skScene)
XCPShowView("Live SKView: Iitomo", view: skView)
- 今回は無しで...
Reference
Author And Source
この問題について(SpriteKit を用いて タモさん を神と崇める feat. Playground), 我々は、より多くの情報をここで見つけました https://qiita.com/r-fujiwara/items/a2966eedf17ff45e2962著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .