GUI device for throwing a ball
Posted
by
Fredrik Johansson
on Game Development
See other posts from Game Development
or by Fredrik Johansson
Published on 2012-11-28T17:53:36Z
Indexed on
2012/11/28
23:16 UTC
Read the original article
Hit count: 334
The hero has a ball, which shall be thrown with accuracy in a court on iPhone/iPad. The player is seen from above, in a 2D view. In game play, the player reach is between 1/15 and 1/6 of the height of the iPhone screen. The player will run, and try to outmaneuver his opponent, and then throw the ball at a specific location, which is guarded by the opponent (which is also shown on the screen). The player is controlled by a joystick, and that works ok, but how shall I control the stick?
Maybe someone can propose a third control method?
I've tried the following two approaches:
Joystick:
- Hero has a reach of 1 meter, and this reach is marked with a semi-opaque circle around the player.
- The ball can be moved by a joystick. When the joystick is moved south, the ball is moved south within the reach circle. There is a direct coupling with the joystick and the position of the ball. I.e. when the joystick is moved max south, the ball is max south within the player reach.
- At each touch update the speed is calculated, and the Box2d ball position and ball speed are updated. NB, the ball will never be moved outside the reach as long as the player push the joystick.
- The ball is thrown by swiping the joystick to make the ball move, and then releasing the joystick. At release, the ball will get a smoothed speed of the joystick.
Joystick Problem:
- The throwing accuracy gets bad, because the joystick can not be that big, and a small movement results in quite a large movement of the ball.
- If the user does not release before the end of the joystick maximum end point, the ball will stop, and when the user releases the joystick the speed of the ball will be zero. Bad...
Touch pad
- A force is applied to the ball by a sweep on a touchpad.
- The ball is released when the sweep is ended, or when the ball is moved outside the player reach.
- As there is no one to one mapping between the swipe and the ball position, the precision can be improved. A large swipe can result in a small ball movement.
Touch Pad Problem
- A touchpad is less intuitive. Users do not seem to know what to do with the touch pad. Some tap the touchpad, and then the ball just falls to the ground.
- As there is no one-to-one mapping, the ball can be moved outside the reach, and then it will just fall to the ground. It's a bit hard to control the ball, especially if the player also moves.
© Game Development or respective owner