Event
Sprite
សំរាប់
Event
មួយនេះវាជា Sprite event ដែលត្រូវបានប្រើជាមួយនឹង
Sprite Objects។ សំរាប់ events ទាំងនេះត្រូវបានបង្កើតឡើងនៅពេលដែល
Sprite animation មាន event។ ដូចនេះនៅពេលដែល
animation stops, loops or plays the next frame
វាមាន
Properties
Event.phase:
វាជា
String
indicating ដែលជា phase នៅពេលដែល sprite
object animation ដែលនៅក្នុងះ
Began:
the sprite began playing
Ended:
the sprite finished playing
Bounce:
the sprite bounces from forward to backward while playing
Loop:
the sprite loops from the beginning of the sequence
Next:
the sprite plays a subsequent frame that’s none of the above phrases
សូមមើលកូដះ
If
the sprite has 4 frames, then here are the phase-frame
scenarios:
--
loop
twice
began 1
next 2
next 3
next 4
loop 1
next 2
next 3
ended 4
--
loop
infinitely, no bounce
(Same as above
but continues forever. No 'ended' ever occurs)
--
loop
infinitely, bounces
began 1
next 2
next 3
bounce 4
next 3
next 2
loop 1
next 2
...
--
loop
twice, bounces
began 1
next 2
next 3
bounce 4
next 3
next 2
loop 1
next 2
next 3
bounce 4
next 3
next 2
ended 1
Example
local
function spriteListener( event )
print( event.name, event.sprite,
event.phase, event.sprite.sequence )
end
--
Add
sprite listener
instance:addEventListener(
"sprite", spriteListener )
Event.target:
វាជា
Sprite
ដែលបង្កើតនៅ event ដែល current
properties អាច accessed ទៅបានតាមរយះ Property។ ឧះ event.target.sequence នឹងផ្តល់នៅ current
sequence សំរាប់ Sprite
សូមមើលកូដះ
local
function spriteListener( event )
print( "Sprite event: ",
event.target.sequence, event.phase )
end
--
Add
sprite listener
instance:addEventListener(
"sprite", spriteListener )
No comments:
Post a Comment