![](/img/trans.png)
[英]How to fixate the camera on the player, so when the player moves the camera will follow
[英]How do I make it so the background “switches” when the player moves to the edge of the screen, and teleports them back, as if moving through a world
我正在 Java 中制作基於圖塊的自上而下 RPG,並且我希望在玩家到達屏幕邊緣時改變背景(和所有其他對象)。 然后玩家將被傳送到屏幕的另一側,給人一種運動的錯覺。
像這樣 -來自“勇士不為人知的故事”的例子
到目前為止,我已經嘗試了所有對我有意義的方法,我輸入了代碼,當玩家的 x 坐標低於 10 時,他們會被傳送到另一側,並且背景會移動一個屏幕。
int Screen = 1;
//Player Screen Change
if(Player.x < 10 && Screen == 1) {
Player.x = 590;
Screen = 2;
}
這樣做的結果是玩家傳送過來,但背景要么沒有改變,要么只是快速閃爍不到一秒鍾。
啊哈,我想通了,我不得不將 int Screen 從方法中移出,並將其更改為 static 變量。 謝謝你讓我回來看看 go :)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.