Create a gist now

Instantly share code, notes, and snippets.

@natmark /Scene1.swift Secret
Last active Dec 12, 2017

Embed
//
// 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