簡體   English   中英

Java LibGDX中的旋轉精靈

[英]Rotating sprite in java LibGDX

對於定義紋理的精靈,有一個資產類,然后將該精靈作為該紋理工作表,並帶有該工作表的坐標。 這是我要旋轉的精靈。 我得到了使用Sprite Batch旋轉它的建議(旋轉到我的觸摸輸入:

batch.draw(TextureRegion region,
                 float x,
                 float y,
                 float originX,
                 float originY,
                 float width,
                 float height,
                 float scaleX,
                 float scaleY,
                 float rotation)

我得到錯誤:

SpriteBatch類型的draw(Texture, float, float, int, int, int, int)不適用於參數(Sprite, int, int, int, int, int, int, int, float)

有沒有一種將子畫面投射到紋理的方法,或者有一種更好的旋轉它的方法,它只是不起作用,請幫助!

您可以簡單地使用rotation(float degree) 設置精靈相對於當前旋轉的旋轉角度。

您必須在類的render方法中使用rotation(float degree)。

Sprite類文檔中所述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM