В полицейском участке царило обычное утреннее спокойствие. Близилось к десяти часам, когда туда вошла пожилая дама лет семидесяти, ведя за поводок упитанного рыжего пса. Собака беспокойно подпрыгивала на месте, виляя хвостом, её поведение явно выходило за рамки нормы.
“Доброе утро. Мне нужно к вашему начальству,” ровным голосом произнесла женщина.
Дежурный офицер растこの翻訳ドキュメントはスクリプトによって出力・同期されています内容が怪しいときはGitHubにissueを追加したり[英語の原文](https://simon-ritchie.github.io/apysc/en/animation_reverse.html)の確認をお願いします
# animation_reverse インターフェイス
このページでは`animation_reverse`メソッドのインターフェイスについて説明します
## インターフェイス概要
`animation_reverse`メソッドのインターフェイスは逆方向のアニメーションを開始しますこのインターフェイスは`animation_play`や`animation_pause`メソッドなどと連携して動作します
## 基本的な使い方
`animation_reverse`メソッドは`animation_play`や`animation_pause`メソッドなどと連携して動作します以下の例のようにもし`animation_play`メソッドを呼び出してから`animation_reverse`メソッドを呼んだ場合アニメーションは逆方向に動きます
“`py
# runnable
import apysc as ap
ap.Stage(
stage_width=300,
stage_height=150,
background_color=ap.Color(“#333”),
stage_elem_id=”stage”,
)
sprite: ap.Sprite = ap.Sprite()
sprite.graphics.begin_fill(color=ap.Color(“#0af”))
rectangle: ap.Rectangle = sprite.graphics.draw_rect(x=50, y=50, width=50, height=50)
animation: ap.AnimationBase = rectangle.animation_x(
x=100,
duration=3000,
delay=1000,
easing=ap.Easing.EASE_OUT_QUINT,
)
def on_animation_complete_1(e: ap.AnimationEvent[ap.Rectangle], options: dict) -> None:
“””
The handler that animation calls when its end.
Parameters
———-
e : ap.AnimationEvent
Event instance.
options : dict
Optional arguments dictionary.
“””
rectangle.animation_reverse()
def on_animation_complete_2(e: ap.AnimationEvent[ap.Rectangle], options: dict) -> None:
“””
The handler that animation calls when its end.
Parameters
———-
e : ap.AnimationEvent
Event instance.
options : dict
Optional arguments dictionary.
“””
rectangle.animation_play()
animation.animation_complete(on_animation_complete_1)
animation_reverse: ap.AnimationBase = rectangle.animation_x(
x=50,
duration=3000,
delay=1000,
easing=ap.Easing.EASE_OUT_QUINT,
)
animation_reverse.animation_complete(on_animation_complete_2)
animation.play()
ap.save_overall_html(dest_dir_path=”./animation_reverse_basic_usage_1/”)
“`
また以下のように`animation_pause`メソッドを呼び出してから`animation_reverse`メソッドを呼んだ場合アニメーションは一時停止した状態のまま逆方向のアニメーションの設定が行われ`animation_play`メソッドが呼ばれた際に逆方向のアニメーションが開始されます:
“`py
# runnable
import apysc as ap
ap.Stage(
stage_width=300,
stage_height=150,
background_color=ap.Color(“#333”),
stage_elem_id=”stage”,
)
sprite: ap.Sprite = ap.Sprite()
sprite.graphics.begin_fill(color=ap.Color(“#0af”))
rectangle: ap.Rectangle = sprite.graphics.draw_rect(x=50, y=50, width=50, height=50)
animation: ap.AnimationBase = rectangle.animation_x(
x=100,
duration=3000,
delay=1000,
easing=ap.Easing.EASE_OUT_QUINT,
)
def on_animation_complete_1(e: ap.AnimationEvent[ap.Rectangle], options: dict) -> None:
“””
The handler that animation calls when its end.
Parameters
———-
e : ap.AnimationEvent
Event instance.
options : dict
Optional arguments dictionary.
“””
rectangle.animation_pause()
rectangle.animation_reverse()
def on_timer(e: ap.TimerEvent, options: dict) -> None:
“””
The handler that timer calls.
Parameters
———-
e : ap.TimerEvent
Event instance.
options : dict
Optional arguments dictionary.
“””
rectangle.animation_play()
timer: ap.Timer = e.this
timer.stop()
animation.animation_complete(on_animation_complete_1)
animation_reverse: ap.AnimationBase = rectangle.animation_x(
x=50,
duration=3000,
delay=1000,
easing=ap.Easing.EASE_OUT_QUINT,
)
animation.play()
ap.Timer(on_timer, delay=3000).start()
ap.save_overall_html(dest_dir_path=”./animation_reverse_basic_usage_2/”)
“`
## animation_reverse API
特記事項: このAPIドキュメントはドキュメントビルド用のスクリプトによって自動で生成・同期されていますそのためもしかしたらこの節の内容は前節までの内容と重複している場合があります
**[インターフェイスの構造]** `animation_reverse(self) -> None`
**[インターフェイス概要]**
現在のアニメーションの再生方向を逆方向へと変更しますこの設定は`animation_play`や`animation_pause`メソッドなどのインターフェイスと連携して動作します
**[コードサンプル]**
“`py
>>> import apysc as ap
>>> stage: ap.Stage = ap.Stage()
>>> sprite: ap.Sprite = ap.Sprite()
>>> sprite.graphics.begin_fill(color=ap.Color(“#0af”))
>>> rectangle: ap.Rectangle = sprite.graphics.draw_rect(
… x=50, y=50, width=50, height=50
… )
>>> _ = rectangle.animation_x(
… x=100,
… duration=1500,
… easing=ap.Easing.EASE_OUT_QUINT,
… ).animation_complete(
… on_animation_complete_1
… ).play()
>>> def on_animation_complete_1(
… e: ap.AnimationEvent[ap.Rectangle], options: dict
… ) -> None:
… rectangle.animation_reverse()
… rectangle.animation_play()
“`

