※この翻訳ドキュメントはスクリプトによって出力・同期されています。内容が怪しそうな場合はGitHubにissueを追加したり英語の原文の確認をお願いします。
AnimationBaseクラス start インターフェイス¶
このページでのAnimationBaseクラスのstartメソッドのインターフェイスについて説明します。
インターフェイス概要¶
startメソッドは対象のアニメーションを開始します。各アニメーションのインターフェイスはAnimationBaseクラスのサブクラスのインスタンスを返却します。例えばanimation_moveやanimation_xなどが該当し、それらのインスタンスはこのstartメソッドを持っています。
基本的な使い方¶
特記事項: 以下のコードのようにアニメーションを開始するにはanimation_xなどの各アニメーションのインターフェイスを呼び出した後にstartメソッドを呼ぶ必要があります。
import apysc as ap
ap.Stage(
    stage_width=200,
    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_x: ap.AnimationX = rectangle.animation_x(x=100, duration=3000, delay=3000)
animation_x.start()
ap.save_overall_html(dest_dir_path="./animation_base_start_basic_usage_1/")
シンプルに書くためにメソッドチェーンを使う形でも書くことができます:
import apysc as ap
ap.Stage(
    stage_width=200,
    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)
rectangle.animation_x(x=100, duration=3000, delay=3000).start()
ap.save_overall_html(dest_dir_path="./animation_base_start_basic_usage_2/")
start API¶
特記事項: このAPIドキュメントはドキュメントビルド用のスクリプトによって自動で生成・同期されています。そのためもしかしたらこの節の内容は前節までの内容と重複している場合があります。
[インターフェイスの構造] start(self) -> 'AnimationBase'
[インターフェイス概要]
現在の設定を使ってアニメーションを開始します。
[返却値]
self: AnimatonBaseこのインスタンス。
[コードサンプル]
>>> 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).start()