How to make a dragable ball

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

How to make a dragable ball

Postby E-Nature » Wed Mar 24, 2010 4:28 pm

Hi all
After working several months on my first Android app I think I'm ready to make my first Android game. The thing is that I have no idea how to start. I found some beginner tutorials but none of them covered what I want to do.

I want to have a sprite (it's gonna be a 2D game) which can be dragged around with the touchscreen. It also can be tossed and should jump like a ball which falls to the floor.

That's pretty much the first thing I need for my game.
Does anyone have help for me, how I can do such a thing?

Thanks a lot for any help in advance!
Dominik
User avatar
E-Nature
Experienced Developer
Experienced Developer
 
Posts: 93
Joined: Mon Nov 16, 2009 3:39 pm

Top

Re: How to make a dragable ball

Postby mb_zi » Tue Mar 30, 2010 3:35 am

E-Nature wrote:Hi all
After working several months on my first Android app I think I'm ready to make my first Android game. The thing is that I have no idea how to start. I found some beginner tutorials but none of them covered what I want to do.

I want to have a sprite (it's gonna be a 2D game) which can be dragged around with the touchscreen. It also can be tossed and should jump like a ball which falls to the floor.

That's pretty much the first thing I need for my game.
Does anyone have help for me, how I can do such a thing?

Thanks a lot for any help in advance!
Dominik


if your having a 2d game then there will be no z problems. with the onTouchListener you get current x and y. take away old x and y from new x and y to see what direction the user has "swiped" on the screen. based on the difference you can work out how "far" the user wants to throw the ball(however youll have to set the boundries yourself etc).

as for the bounce, you know the hieght of the ball, just have a small animation which halfs the height each bounce e.g. if the ball falls from y height, then the ball should bounce up to y/2. the next bounce the ball should only reach y/4. you can use the same approach with how fast its moving left and right.

p.s. im very tired so theres a few grammatical issues above aha
mb_zi
Junior Developer
Junior Developer
 
Posts: 17
Joined: Sat Feb 27, 2010 2:16 am

Re: How to make a dragable ball

Postby Sagar jacky » Thu Dec 06, 2012 12:18 pm

I have made some creative android games after reading your post and I would definitely thank you for the great effort you have put on this android game developing tutorial. Hope to see more great articles from your end. buy gripgo phone mount"
Sagar jacky
Junior Developer
Junior Developer
 
Posts: 19
Joined: Wed Nov 21, 2012 6:03 am

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest