简体   繁体   English

在AndEngine中检测屏幕边界并防止精灵超出其边界

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

Currently, I am doing this 目前,我正在这样做

@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;
}

But Still,in Landscape mode it went beyond screen from right side. 但是,在横向模式下,它从右侧超出了屏幕。 How can restrict a sprite to leave screen? 如何限制精灵离开屏幕?

A really shitty way of doing it is to add an invisible physics bidy so it cannot pass. 一种非常糟糕的方法是添加一个看不见的物理构造,使其无法通过。 Or in the sprite and override onManaged update that will allow you to check collisions 或在精灵中并覆盖onManaged更新,这将使您检查冲突

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM