AndEngine analog and areatouched problems? - android

I am using AndEngine GLES 2.0 and well I've been reading a lot in search for an answer but I just can't find anything... what happens is that I am doing a game and I have AnalogOnScreenControl on the left side of the screen, and 2 onAreaTouched "buttons", so when I am using the analog and move the finger all the way to any "button", when I lift my finger, the analog is still "moving" as if I still had my finger on the screen... So is there any way to prevent this? like setting an area of response for the analog? I don't know if I explained myself well... but any help is very much appreciated!

Try to enable Multi touch:
in your onCreateEngineOptions() add : options.getTouchOptions().setNeedsMultiTouch( true );
Now when you have your finger on the joystick and press a button with another finger, it will reference a different pointerID.

Related

pygame - link an object to mouse event

I am trying to develop a game for Android using pygame.
It would be a platformer. To move the main charachter, I would make the game to wait for mouse events (like pygame.MOUSEBUTTONDOWN).
In order to do that on mobile, I'd like to create a graphic representation of a joypad with arrow keys to be shown on the bottom left corner of the screen.
Now, when the user touches one of the arrows, a MOUSEBUTTONDOWN event should be triggered and the charachter should move accordingly.
My question is: since the "joypad" object is a mere draw, how can I link it to the event with pygame?
Is there a way to do so? Should I use the pixel coordinates of the arrow keys of the joypad or is there a better choice?
As far as I know this is not possible.
When handling input, mouse input and touch input are to be handled separately.
So to answer the 2 questions you listed at the end:
As far as I know there is no way to implement this functionality.
You could use the pixel coordinates of the arrows. However you can use Rects for that and test if the place of mouse input/touch input is inside the arrow button Rect with the collidepoint method
You can achieve that as follows:
arrow_left.collidepoint(mouse_x, mouse_y)
I hope this answer helped you!

Multi-touch drawing : action_cancel when the palm touches the screen

I'm working on an android application on tablet to draw every points touched by the finger or the hand. It is very important for the application to track not only the fingers but also the palm (even if it's not drawing the exact touched area but only a thin path, as long as we can see the movement of the palm it's fine). A good example of what I want to do is the "show pointer location" in the Android developer menu : if the drawing could be exactly like this, that would be perfect.
I managed to code a multi-touch drawing app, but the problem I have here is that every time the touched area is too wide (for example when I touch the screen with my entire palm), the application stops drawing (even the fingers drawings stops) and I have this error in the log : [ViewRootImpl] action cancel - 1, eccen:1.4225352 (the number after "eccen" changes depending on the size of my palm touch).
I'm quite new to android, I spent a lot of time searching how I could prevent this action_cancel but I couldn't find anything that makes it work... I tried to prevent the parent views from taking control of the onTouch events, but it didn't work. So if you have any idea of how I can manage that, it would be great :)
Thanks !
(English is not my native language, so don't hesitate to ask me to reformulate is something is not clear)

App Inventor 2 - How to make a sprite walk to the position of touch?

I want the sprite to walk towards the position of touch. To be more precise I want it to move like the main sumo in this game: https://youtu.be/Gj5CwgFUbI0?t=56s
The buttons provide pixel by pixel movement but I've to keep pressing them again and again to reach a point.
The Canvas event directly puts the sprite to the position touched.
This was answered by Ghica on Mit App Inventor forum and I just made a few edits. I used blank png 10*10 pixel as a Target Sprite.
.aia file
The logic should be like this, but i can't make it works, it's always freeze when the button touched.
My guess is because MIT App inventor doesn't support multi threading. Sorry that was as far as i can help.

How to move an object in four different direction by pressing on screen in android

This is for learning purpose. I have a small block that should respond to touch. IF i touch top of the screen it should move forward and right if i touch the right side of the screen.Could someone help me with the code and also what topic should i read to learn about this.
What part are you having trouble with, detecting where someone touched, drawing an object or moving an object?
Regardless I would start with some Android tutorials that walk you through creating an app with an object on it, once you have done that the rest should become obvious--it's just getting started that's hard.
Detect touch: How do I detect touch input on the Android
Moving Ojbects: http://obviam.net/index.php/moving-images-on-the-screen-with-androi/

Android - Detect Path of Complex Drag

I am recently getting into Android programming and want to make a simple game using 2D canvas drawing. I have checked out the Lunar Lander example and read up on some gestures, but it looks like I can only detect if a gesture occurred. I am looking to do a little more complicated detection on a swipe:
I want to make a simple game where a user can drag their finger through one or more objects on the screen and I want to be able to detect the objects that they went over in their path. They may start going vertically, then horizontally, then vertically again, such that at the end of a contiguous swipe they have selected 4 elements.
1) Are there APIs that expose the functionality of getting the full path of a swipe like this?
2) Since I am drawing on a Canvas, I don't think I will be able to access things like "onMouseOver" for the items in my game. I will have to instead detect if the swipe was within the bounding box of my sprites. Am I thinking about this correctly?
If I have overlooked an obvious post, I apologize. Thank you in advance!
I decided to implement the
public boolean onTouchEvent(MotionEvent event)
handler in my code for my game. Instead of getting the full path, I do a check to see which tile the user is over each time the onTouchEvent fires. I previously thought this event fired only once on the first touch, but it fires as long as you are moving along the surface of the screen, even if you haven't retouched.

Categories

Resources