久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

何時在 libgdx 中使用演員?什么是缺點和優點?

When to use actors in libgdx? What are cons and pros?(何時在 libgdx 中使用演員?什么是缺點和優點?)
本文介紹了何時在 libgdx 中使用演員?什么是缺點和優點?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我正在編寫簡單的太陽系模擬器.這是我的第一個 libgdx 項目.我在主菜單中使用了舞臺和演員,并且非常方便,尤其是觸摸事件處理.但是......看看這些例子,我發現沒有人在實際游戲邏輯中使用演員.如果我應該使用actor作為行星類的父級,或者只是編寫我自己的類,我會徘徊.行星是不可觸摸的,它們只會在幀之間移動,因此動作 MoveBy 的第三個參數必須是幀之間的時間.這就是缺點.使用 Actors 的優點是什么?

I'm writing simple solar system simulator. This is my first libgdx project. I'm using a Stage and Actors for the main menu and is pretty handy especially touch events handling. But ... looking at the examples i see nobody uses actors in actual game logic. I wander if i should use actor as a parent of planet class or just write my own class tor that. The planets won't be touchable and they will be moved only between the frames so the third parameter of action MoveBy will have to be time between frames. That are the cons. What are the pros for using Actors?

推薦答案

Actor 的主要優點是動作、命中測試和觸摸事件以及 Actor 組.

The main pros for Actors are Actions, Hit testing and touch events, and Groups of Actors.

如果您的游戲邏輯需要,動作可以快速輕松地進行補間.

Actions make quick and easy tweening if your game logic needs that.

您可以隨時調用 stage.hit(x, y) 以返回第一個返回 true 的參與者,無論您為它編寫的任何命中邏輯(通常檢查 x、y、寬度、高度的邊界).返回此演員或 null 以繼續遍歷演員的命中方法以尋找命中演員.如果沒有命中 Actor,則返回 Null.

You can call stage.hit(x, y) at any time to return the first actor that returns true to whatever hit logic you wrote for it (usually checking bounds with x, y, width, height). return this actor or null to keep iterating through the actors' hit methods looking for a hit actor. Null is returned if no actor is hit.

Hit 用于舞臺的觸摸事件.演員的觸摸方法傳遞局部坐標,舞臺處理對象的重疊,例如如果一個actor覆蓋了另一個actor,使得另一個actor不應該接收touchDown,則在覆蓋actor上返回true以停止對下面"actor的touchDown調用.這也將焦點"設置在返回 true 的 Actor 上,以便調用 Actor 的 touchUp.

Hit is used for the Stage's touch events. The actor's touch methods are passed local coordinates, and the Stage handles overlapping of objects, e.g. if an actor covers another actor such that the other actor shouldn't receive touchDown, return true on the covering actor to stop the calling of touchDown on actors "beneath". This also sets 'focus' on the actor that returns true so that Actor's touchUp will be called.

您可以將 Actor 組合在一起,以將整個 Actor 組作為一個單元執行動作、觸摸事件等.

You can group actors together to perform Actions, touch events, etc on the entire Group of Actors as a single unit.

一些缺點:演員需要一個在某種程度上限制功能的舞臺.許多編碼人員使用其他邏輯來確定游戲對象狀態,而不是 scene2d 動作(例如 box2d).如果您將 Actors 用于游戲對象,您可能需要兩個階段,一個用于 ui,一個用于游戲世界.如果你不使用它們,你可能會使用你自己的 SpriteBatch 和 Camera.請記住,Actor 只有一個抽象的 Draw 方法,所以無論如何您仍然需要創建繪制邏輯.您可能會將 TextureRegion 或 Sprite 作為 Actor 的私有字段.如果您想使用自己的更新邏輯,您可以重寫 act(float delta) 方法來獲取增量時間(如果使用 Actions,請調用 super.act(delta)).

Some Cons: Actors require a stage which limits functionality somewhat. Many coders use other logic to determine game object state, rather than the scene2d Actions (e.g. box2d). If you use Actors for game objects, you will probably want two Stages, one for ui and one for game world. If you don't use them you'll probably be using your own SpriteBatch and Camera anyway though. And keep in mind that Actors only have an abstract Draw method so you will still need to create draw logic anyway. You'll probably keep a TextureRegion or Sprite as a private field for the Actor. If you want to use your own update logic, you can override the act(float delta) method to get the delta time (call super.act(delta) if you use Actions).

因此,如果您有自己的邏輯并且不會使用 Stage 提供的大部分功能,請節省一些資源并推出您自己的特定于應用程序的解決方案.如果您可以在不限制所需功能的情況下使用某些專業人士,那么請為游戲邏輯進行第二階段.

So if you have your own logic and won't use much of what Stage has to offer, save some resources and roll your own application-specific solution. If you can use some of the pros without limiting needed functionality then go for a second Stage for the game logic.

這篇關于何時在 libgdx 中使用演員?什么是缺點和優點?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 99久久精品免费看国产小宝寻花 | 日本一区二区高清不卡 | www日韩欧美 | 中文字幕在线视频观看 | 欧美日韩国产精品一区 | 天堂中文在线观看 | 看真人视频一级毛片 | 国产精品一区二区av | 在线观看免费观看在线91 | 一二三四在线视频观看社区 | 久久久久久免费毛片精品 | 99精品视频一区二区三区 | 日韩免费福利视频 | 国产精品国产精品国产专区不卡 | 一级在线毛片 | 久草色播| 国产精品久久久久久网站 | 欧美成人专区 | 日韩精品 电影一区 亚洲 | 一区二区三区四区免费视频 | 人妖videosex高潮另类 | 久久久久91 | 久久精品视频亚洲 | 9191av| 91xxx在线观看 | 亚洲精品久久久久久久久久久 | 2019天天操| 国产精品九九九 | 久久精品成人 | 欧美一区二区三区高清视频 | 欧美视频一区二区三区 | 波多野结衣二区 | 日本精品在线一区 | 青青草社区 | a在线观看 | 精品一区av | 国产成人精品免费视频大全最热 | 日韩午夜一区二区三区 | 国产精品久久久久久久久久妇女 | 毛片a级毛片免费播放100 | 香蕉一区二区 |