mirror of
https://github.com/lxsang/Diya-API.git
synced 2024-12-27 03:48:21 +01:00
2e4c73f8cf
- fix: TF update bug on scale - fix: Use local coordiate for Polygon points - Add timer node for basic animation - Dirty processing nodes are monitored by rootnode - refactory code
69 lines
1.4 KiB
Smalltalk
69 lines
1.4 KiB
Smalltalk
Class {
|
|
#name : #DiyaTimerNode,
|
|
#superclass : #DiyaMetaNode,
|
|
#instVars : [
|
|
'timeout',
|
|
'elapsedTime',
|
|
'handlers'
|
|
],
|
|
#category : #'Diya-Graphics'
|
|
}
|
|
|
|
{ #category : #accessing }
|
|
DiyaTimerNode class >> timeout: ms [
|
|
^ self new timeout: ms; yourself
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
DiyaTimerNode class >> timeout: ms do: aBlock [
|
|
^ (self timeout: ms) onTimeout: aBlock;yourself
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
DiyaTimerNode class >> timeout: ms doOnce: aBlock [
|
|
^ (self timeout: ms) onceTimeout: aBlock;yourself
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
DiyaTimerNode >> delta [
|
|
^ DiyaClock uniqueInstance delta asMilliSeconds
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
DiyaTimerNode >> initialize [
|
|
super initialize.
|
|
elapsedTime := 0.
|
|
handlers := OrderedCollection new.
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
DiyaTimerNode >> onTimeout: aBlock [
|
|
handlers add: aBlock
|
|
]
|
|
|
|
{ #category : #'as yet unclassified' }
|
|
DiyaTimerNode >> onceTimeout: aBlock [
|
|
|newBlock|
|
|
handlers := OrderedCollection new.
|
|
newBlock := [ :node | aBlock value: node. self remove ].
|
|
handlers add: newBlock
|
|
]
|
|
|
|
{ #category : #stepping }
|
|
DiyaTimerNode >> step [
|
|
elapsedTime := elapsedTime + self delta.
|
|
elapsedTime >= timeout ifFalse:[^ self].
|
|
handlers do:[:e| e value: self ].
|
|
elapsedTime := 0
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
DiyaTimerNode >> timeout [
|
|
^ timeout
|
|
]
|
|
|
|
{ #category : #accessing }
|
|
DiyaTimerNode >> timeout: anObject [
|
|
timeout := anObject
|
|
]
|