I have a slider at the bottom of my screen. It has a fixed Y but can move either way in the X direction. I wanted to use CoreMotion to move the slider back and forth when the phone is tilted. I got the sense that I might need a gravity behavior and DeviceMotion, but I'm not quite sure exactly how to do this. Somebody please help. To give a picture of what things look like, I have provided an image below. Ignore the ball. It currently has no relevance.
Related
I am working on a small education demo which should measure height and width of the object using iOS camera.
EDIT:
I have a new theory to measure the width of an object.
In above image, if i can get Angle α and Angle ß, i can get width of the unknown side by using trigonometry formulas. I have the values of b1 and b2 already.
OLD:
Right now, i am focusing on measuring length only.
As per my knowledge it should be 3 step process.
User snaps one end of the object.
User snaps other end of the object.
User snaps center of the object. (Suggest me a better way for these please)
I get the approximate measurements using above process, but for the 3rd step, in which user snaps the center of the object. I want to show pointer location on screen (as camera overlay) to help user determine the center of the object.
This is how i am doing it right now.
How can i draw pointer location for 3rd step?
Note: Please suggest alternative/best way to make it possible. I would love another suggestions. Thanks.!!
First of all I must appreciate your work you have done till now. Another good thing is the way of explaining, salute!!!!!
After reading of your question, I feel that you dont need code, you can do it. I think you need direction only.
As per your explanation, you want to record angle of rotation of the device.
If you want to measure angle of rotation, you have to use compas readings. But compas readings will change if user tild the device. So you have to use accelerometer to measure tilding of device.
In short you have to make some combination and equation of both compas and accelerometer readings. Use compas to measure angle and use accelerometer to measure tilding of device.
If you want further information to implement it, you can ask me.
Hope this will help you....
I really would like to know how to make an image view move when I touch the screen. Though, I would like specific coordinates to be specific directions.
Imagine breaking up the screen into 9 identical squares, the middle being my image view, the rest being the direction in which they are pointing.
If you see this please don't flag it down, tell me why you want to flag it down and I'll fix it. I've spent over 6 hours trying to find out how to do this. Thanks for your time and consideration.
I am newbie in IOS Gaming, and i need to create a game using Sprite Kit framework for functionality similar to angry bird pulley system, and also wants to find the distance the object is travelled from the pulley to its landing.
Can anyone help me out with this, i would be thankfull for it.
Thanks in advance.
One way you could code a slingshot effect would to use a starting point on the screen at let's say (x=100,y=100). You would display a SpriteNode of a slingshot with the Y centered at the (100,100).
The next step would be to use touchesBegan:withEvent: in the area of the slingshot to let your code know the player is looking to shoot the slingshot.
You would use touchesMoved:withEvent: to track how far back (how much tension) the player is pulling back from the slingshot.
The release would be triggtouchesEnded:withEvent. Based on how far the touch began (x=100) and how far back is was released (for example x=30), you can apply force like this:
float forceUsed = startTouchX - endTouchX;
[_projectile.physicsBody applyForce:CGVectorMake(forceUsed, 0)];
If you are looking to angle the shot you would also have to track Y and use that variable instead of the 0 above.
As for calculating distance between 2 points on the screen, it boils down to x and y coordinates. Subtract objectA.position.x from objectB.position.x
Things can get a lot more complex of course but that all depends on what you want to do in your code. Hope this helps.
P.S. The touches above are all part of the UIResponder Class.
Hi fellow programmers!
What I'm trying to do:
I have an image placed in the center of the screen. When I put my finger on this image, and rotate my finger, the image should rotate as well. When i release the finger, i would like the image to decelerate for x period of time. (Let's say that it should decelerate slowly). Basically I'm trying to develop a Spin-the-bottle application, but I can't figure out the velocity part.
What I've tried:
I've used this to get the one finger rotation, and it works great so far, but it doesn't include the velocity part. And honestly, I have no idea, how to calculate the velocity.
What I'm asking of you:
A "simple" way of doing one-finger-rotation with velocity, of an UIImageView in a normal UIViewController. (Or just using this method to the rotation part, and somehow implement velocity.) Examples are appreciated!
If you have any questions, please comment!
Thanks in advance. :)
I'm trying to make a circular UIView animate in a particular direction until it collides with the borders of the view (which is full screen, so basically the borders of the device), at which point it will reflect off it and continue on its way infinitely. However, I'm not really sure how to pose my question, so I'm having trouble finding any information on it. I already have the view, the direction it will move in, and its velocity. I'm just not sure how to handle an animation like that.
Any advice is much appreciated! Thanks!
Use a CADisplayLink to continuously update the position of the view, synced with the refresh rate of the screen. The update method that that display link triggers will take into account the current x and y velocity of the view and update the frame based on it. If at ever point the x- or y-coordinate goes under or over a limit (0 or screen width/height), reverse the appropriate velocity value and recalculate the position.