Skip to content

Instantly share code, notes, and snippets.

@natmark
Last active December 12, 2017 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natmark/1b5fd06c7d679e8ccb8d888a73b64f48 to your computer and use it in GitHub Desktop.
Save natmark/1b5fd06c7d679e8ccb8d888a73b64f48 to your computer and use it in GitHub Desktop.
//
// Scene1.swift
// ipad-pitagora
//
// Created by AtsuyaSato on 2017/12/12.
// Copyright © 2017年 Atsuya Sato. All rights reserved.
//
import ProcessingKit
import simple_tween
extension PitagoraView {
func setupScene1() { // Tween経由で実行時間の設定と、setup関数とdraw関数のセレクタを準備する
sceneInfos[Scene.scene1.rawValue] = (Tween(3), #selector(setup1), #selector(draw1))
}
func setup1() { // シーン開始時に1度だけ呼ばれる
background(255, 255, 255)
}
func draw1() { // Tweenの再生が終わるまで、毎フレーム呼ばれる
let x = lerp(sceneInfos[Scene.scene1.rawValue].tween.position, min: 0, max: Double(width))
fill(255, 0, 0)
ellipse(CGFloat(x), 100, 100, 100)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment