简体   繁体   中英

How to make a projectile trajectory in andEngine using Box2d?

I am new to gaming world development in android, as its reputation precedes the obvious choice in development was and-engine and Box2d for physics. So far I have managed to get a hold of basic functionality of the engine and methods...

But few or more things are not clear so far..Which method to override when dragging a sprite on the scene?

I am doing all the experimentation in onActionMove method, which is found in onAreaTouched method... Previously, I asked the same query on another forum, and someone advised me to go through this post and port it into java code. I tried to convert it to the best of my abilities, but in vain. Could someone possibly guide me through the procedure and methods to look into in order to achieve the functionality, or give a detailed walk-through the flash version of the code.

Cheers.

This is a basic listener for that, expand it according to your needs.

mScene.setOnAreaTouchListener(new IOnAreaTouchListener() {
    @Override
    public boolean onAreaTouched(TouchEvent pSceneTouchEvent, ITouchArea pTouchArea, float pTouchAreaLocalX, float pTouchAreaLocalY) {
        if (pSceneTouchEvent.getAction() == MotionEvent.ACTION_MOVE) {
            sprite.setPosition(pSceneTouchEvent.getX(), pSceneTouchEvent.getY());
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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