簡體   English   中英

在AndEngine中檢測屏幕邊界並防止精靈超出其邊界

[英]Detect the screen boundary and prevent the sprite from going beyond it in AndEngine

目前,我正在這樣做

@Override
public EngineOptions onCreateEngineOptions() {
mCamera = new BoundCamera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED,
new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), mCamera);
mCamera.setBoundsEnabled(true);
return engineOptions;
}

但是,在橫向模式下,它從右側超出了屏幕。 如何限制精靈離開屏幕?

一種非常糟糕的方法是添加一個看不見的物理構造,使其無法通過。 或在精靈中並覆蓋onManaged更新,這將使您檢查沖突

暫無
暫無

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

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