I want to implement a gaming scenario where a ball keeps moving continuously, hitting and bouncing off the wall.
How can I implement this, taking into account that path should be random?
I tried ObjectAnimator, but which always require an x or y coordinates specified.
Any idea?
Related
I am trying to develop an Android app which is trying to draw a perfect line directly in front of me. My reference point is my phone, which means that the line has to parallel to my phone's left side.
I have following issues:
I am using Sceneform, so there is no "onSurfaceCreated" callback.(?)
I assume that the white-dots shows the surface. But, then I think if there is a detected surface then I can place a Shape on it. But is can not happen sometimes. And sometimes, I can place a Shape even if there are no visible white-dots.
When I try to draw a line between the points (0,0,0) to (1,0,0), it is not always parallel to the left side of my phone. I assume that the reason of this is related with the following fact :
angle between the left-bottom corner of the detected surface and the left-top corner is not zero. (If we consider the coordinate system as follows : phone's left side is y-axis, bottom is the x-axis.)And this angle changes each time I reopen the app.
These are more theory questions than the implementation. So, I need someone to prove or disprove, or give me guideline.
1) There isn't method like onSurfaceCreated.
2) Not all the detected planes are covered with white-dots. Is is intended because if all the detected planes are rendered with white-dots, it would confuse the users
3) When you talk about the points(0,0,0) and (1,0,0), is it world position or local position? Whether it is world position or local position, you can not draw a line parallel to your left side of phone in the way you approach.
I try to make app like ink hunter, make it to detect object but on live camera overlaped image blink cause every time i detect object again n again in every frame.I read lot about track object but not found any useful algorithm, cause once algorithm i confuse with other algorithm, i very confuse which method or algorithm should i use.
Initially i detect hand written plus sign and get center point of ROI , Now which algorithm should i use to track center point of rect and place image over there.
After detecting plus (+) sign i have to place another image on it, Using copyto() method i place image on it,but cause overlaying image flick every time frame change , So i want once plus sign points are found then track it and place image at the point.
My sample image as below.
Moments m = moments(lrrIMG, true);
Point point = new Point(m.m10 / m.m00, m.m01 / m.m00);
using this code i able to get center point ,Now i have to place image that point and track until it disappear from mobile screen.
My android app is to use GPS to help layout a sports field, like a football field. You enter the dimensions of the rectangle, tell the app which corner you want to start with and which corner you want to go to next. The app will tell you when you have walked far enough. Once you have laid down the first two corners, the app will then direct you to the next corner (logic in the app make sure you only select corners that make sense). This is where the trouble comes in. You may be going clockwise or counter-clockwise. I need to know which way to turn for the third point. I know how far I need to go, and I know how to figure out a right angle, but I don't know how to figure out if I went the right way.
I was thinking about forcing the user to go one way or the other, but the problem is that often times a field is laid out with an obstacle on one side (a street, cornfield, fence, whatever). In that case, you will usually want to start at the obstacle and work your way out.
So, to put the question one other way, given two points, A & B (lat & long), how can I calculate the third point that is at right angle to the segment AB and in the right direction? For example, if the user says they want to start with corner 2 and then corner 8, how do I calculate the gps coordinates for corner 7?
I realize that this is possibly/probably more of a geometry question than an android question, but it may be that there is a specific android solution.
I agree with you that this is not an Android question, but a geometry question. Nothing by default in Android to program this I'm afraid.
Great link that I use to remember how I have to calculate distances on the survace of the earth is http://www.movable-type.co.uk/scripts/latlong.html.
Calculate bearing between given corners (for your example, between 2 and 8)
Calculate bearing for next corner you want to know (bearing between 2 and 8 + 90 degrees)
Find destination point given distance and bearing from start point (start point is 8, use bearing calculated at step 2 and I assume you know the dimensions of the field)
Fairly new at android dev, haven't got any code for this particular step yet so ill try give as much detail as possible. I'm trying to make an ImageView object move around the android view/activity, unlike java im not able to use the random generator to translate it onto an x and or y position on the frame, if anyone could point me on the right direction or more importantly have a good idea on how to do this, that'd be great.
There is a class in android called Random. And there is a function called nextInt() which can give you a random number. You can also calculate the width and height of your screen using DisplayMetrices so that you can keep the image inside the device's screen. And you can also move the ImageView. See this link.
I am developing a mobile game for iOS and Android with Starling. I am very new to this framework. I need to add a sprite to the screen and then have the initial point on the screen that was touched be anchor point 1 and then the user will drag there finger which will adjust the second anchor point until they release their finger from the screen. Imagine several nodes that need connected by a line and you can picture what I am trying to do. The problem is that I can change the pivot to be at the beginning of the line but I dont know how to make the other anchor point work. I also cannot use anything other than a sprite as the line is animated by a sprite sheet. Any help that can be provided is greatly helpful, I have been thinking about this for a while now and can't seem to figure it out. Code is helpful and preferred but just giving me an outline of the concept would help as I can probably figure out code. Thanks!
I don't know actionscript but I'm sure if it is for android the touch event has 3 phases (generally): touch down, touch move, touch up.
You say you only have a sprite so define some variables:
initX, initY, finalX and finalY. All floats (or ints if you cast them). And a couple of booleans: set1 and set2 all false
On touch down you ask if set1== false if so, set initX=eventX and initY=eventY (eventX and eventY would be here the X and Y of the touch event). Then set set1=true
On touch move you do the same as above, with set2. if set2==false, set finalX=eventX and finalY=eventY, then set2=true.
and you draw your sprite from (initX,initY) to (finalX,finalY) or if you're using width/height then finalX-initX for the width, finalY-initY for height.
I hope this helped. I didn't even know starling existed but since it's actionscript it must be pretty close to java in its syntax