I am wondering how to check if the user is performing gesture on our predefined area. I have an criteria and that is , let suppose , If I have a transparent graphics of word "B" on the screen , then user should start filling it with color with gesture (with the touch of his finger). he starts it with the below corner of the B and end up how we write the b when writing with the pencil.
So how to achieve this type of gesture and how to just restrict user to use the gesture on on that part of the screen ? please any idea about it or share me any thing which is similar to it.
Related
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!
I my app I have some shapes , I want to fill the specified color in it using touch and gesture. the user finger finger will move inside the shape to fill the color in it , It has starting point so that it should always start from the right corner until it gets the last corner which should be the ending corner.
is the picture link so that you guys can easily understand what I am trying to say.
in this picture you can see the white space of the center shape , I want to fill it with user finger touch.
I have read to many gesture techniques including the gesture builder , but they are free form drawings , so in my app I have to face do following thing
1. To fill under the predefined shape
2. The shape should be filled in a single way , ie from starting point towards the ending point.
3. in other Examples they are drawing on canvas , in my case What should I use ??
Please answer me of my confusions or at least tell me how to do it, Please give me a starting point.
I'm trying to make an image more interactive by adding gestures (currently I'm thinking about only zoom, might add later depending on the requirement). It's a parking app by the way.
By interactive I mean that user can tap on a part of an image, let's say it's area A and labelled "A", and then a new interactive image will pop up for that area.
I'm pondering whether I should break down the image part by part in order to detect user's tapping location, or should I take the X, and Y coordinate? And if I should take the coordinate, does that mean I have to alter the code so that it'll cover different screen sizes?
Another question is.. I'm thinking of using Djikstra's algorithm for best route to be taken by user, does the algorithm need the image to be whole?
I'm also planning to add marks for vacant and occupied slots, but it is trivial for whether I should split the image to parts or not, right?
I want to create an interactive graphic for my app. It will essentially be a simple picture of a bus line where users can select 2 stops at a time (one for departure times and another for arrivals) I'm not sure how to create this image though, and have it have 20 or so different clickable points. Is there a framework I could use for this? Or is there a way to do this in pure android?
Thanks for the help.
I would suggest writing an onClick listener and using a collection of Rect instances to manage the collision/position of the 'click'. Check out the on click page and the rect page.
One thing to keep in mind are the origin point of your clicks, I'd assume you'll want to use one corner of your image as the point (0,0) and reference everything (clicks and rects) from there.
I would say try to create an ImageView to load your image and set a touch event listener or a click listener to that view. Hard code all places that you want your image to react upon a click.
Check click using an event listener would require you to handle both ACTION_DOWN and ACTION_UP in the MotionEvent object passed in. But it's easier to grab the coordinate of where the user clicks on the page, so you only need one listener but needs to put more work on handling the conversion from the coordinate passed in by MotionEvent to the coordinate on image. This is particular a major issue when your image can be sized larger than the screen size.
Using a click listener would save you from this trouble. As #smitec said, you need to overlay rectangles on your image as "buttons", so you can react to user input based on which buttons they pressed. This way you need to bind listeners to all of them (I suppose) and hard code their positions on your image. But, as mentioned earlier, it saves you from dealing with coordinates later on.
Depending upon the user i may need to move it to right ,left,top or bottom.
Should i use animation for the purpose?
Or is there any method to move image dynamically?
I meant the things in android application
You use animation for a movement that has a distinct start and stop point. For example you might move the image right to left at a button push. It would slide a cross the screen and then appear back at its original position.
If you wanted to move things around this way you could do so by having 2 (or more) copies of the same view.. hiding the view at the old position and showing it again at the new one. You generally won't be stopping this animation between its begin and end point.
If you want some more interactive movement (say move along with the user's finger on the screen), you'll need to make use of the canvas and some touch listeners. In that case I recommend looking up drag and drop samples as they address what is needed for this to happen (and then some).