Harri E
- Forum posts: 3
Apr 10, 2012, 3:51:51 PM via Website
Apr 10, 2012 3:51:51 PM via Website
Hallo,
at first i want to indruduce what i want to do:
I want to create a custom view element which i can handle input events from.
Custom view component should be a real custom figure i draw on myself, no image file.
Lets say e.g a snake.
How i tried to do this:
1.) View class ClickableShape
I created a class ClickableShape inheriting from View.
I overrided the method onDraw where i draw my "snake" figure.
2.) Input event handling
I also overrided the method onTouchEvent of ClickableShape.
But now all "klicks" on any place on canvas is recognised.
What i want to do is just capture the events on the figure itself. Lets say on the snakes body.
Is that possible with standard mechnism?
Maybe i have to get the click coordinates and the coordinates of the sanke body itself and check whether the click coordinates is inside?
If so, is there a known way to get the neccessary information? (Snake as coordinate list?)
Or am i totally on the wrong way? Maybe i took the wrong approach?
Kind regards
Harri E.
at first i want to indruduce what i want to do:
I want to create a custom view element which i can handle input events from.
Custom view component should be a real custom figure i draw on myself, no image file.
Lets say e.g a snake.
How i tried to do this:
1.) View class ClickableShape
I created a class ClickableShape inheriting from View.
I overrided the method onDraw where i draw my "snake" figure.
2.) Input event handling
I also overrided the method onTouchEvent of ClickableShape.
But now all "klicks" on any place on canvas is recognised.
What i want to do is just capture the events on the figure itself. Lets say on the snakes body.
Is that possible with standard mechnism?
Maybe i have to get the click coordinates and the coordinates of the sanke body itself and check whether the click coordinates is inside?
If so, is there a known way to get the neccessary information? (Snake as coordinate list?)
Or am i totally on the wrong way? Maybe i took the wrong approach?
Kind regards
Harri E.
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.