Joystick Tutorial?

Hey everyone

First of all thanks to all those who are still reading the blog and checking out the tutorials. It has been quiet recently due to me travelling on business and Johns wedding and as I’ve said a few times the book is taking up a lot of my time.

That said, I have just finished implementing a touch joystick into Sir Lamorak’s Quest and was wondering if this is a tutorial people would like to see. As I don’t have much time I wanted to see what the interest was be before I did a quick tutorial on it.

There are many games on the iPhone that use joysticks and I’m really pleased with the implementation I’ve now got working. My plan would be to put the code into the tutorial 10 code base.

If your interested drop a comment into this post and next week when I’m back in the UK I’ll get the tutorial done if there is enough interest :o)

Mike

Share:
  • Digg
  • del.icio.us
  • Facebook
  • MySpace
  • Reddit
  • StumbleUpon
  • Technorati
  • TwitThis
  • Design Float
  • DZone
  • email
  • Google Bookmarks
  • LinkedIn
  • Scoopeo
  • Tumblr

30 Comments

CC  on October 8th, 2009

I think that would be a good addition, especially since most touch tutorials seem to *ahem* ignore all but the first touch. Presumably, a joystick game would also require reading touches of other things on screen while the joystick was being used, so showing how to deal with that might be a good exercise in control architecture.

mike  on October 8th, 2009

Hi CC, thanks for the feedback. I agree that being able to correlate touches between calls to touchesMoved is important as this will allow you to recognise which touch is moving the joystick so that other touches to fire say are picked up correctly.

I needed to handle this in Sir Lamorak’s Quest so will certainly be part of the tutorial.

Mike

CC  on October 8th, 2009

Cool.

You should also post some screenshots and general info about Sir Lamorak’s Quest “the game”, in addition to coding techniques you’re sharing. It would be interesting to see the development of the game over time, and may prompt other interesting discussions.

decobot  on October 8th, 2009

Hey I just registered but I’ve been a-lurkin’ for a few weeks. Your tutorials have been a huge help in me trying to get things structured for apps in dev right now. Ummm.. Yeah, joystick logic would help. Actually thats one area I am working on right now in one of my apps: buttons. How to make sure a new tap doesn’t unselect currently pressed buttons, etc. Can’t wait for part 2 of Tutorial 10 to come out. Thanks for this tutorial.

Yuka

Greg  on October 8th, 2009

I’d like to see one!

Simon  on October 8th, 2009

Hi Mike,

That would be very interesting as I’d love to see the process you went through to build the joystick.

Simon

Simon  on October 8th, 2009

On a separate note. I’d also like to know where is best to set the view to landscape. Do I have to make adjustments throughout the project or is it simpler than that?

DjuzeKing  on October 8th, 2009

That would be awesome if you could share your experience!

Ken  on October 8th, 2009

Actually Mikes code already contains 90% of the info required to do the joystick, – it even has the image for it.

All you need to do is enable it, and mod the code to return + and – 1′s for the directions returned by the touches, then in the player.m file alter the Accelerometer code accordingly.

BTW: I think initwithtilelocation is a bit wrong, all entitys initial spawn at the top of the screen then on update move to the correct location. Should the position.x any .y locations be scaled by tilewidth and tileheight ?

Bob  on October 8th, 2009

I’d love to see one as well!

Ken  on October 8th, 2009

Re: BTW – no.. but the do take floats which means you can get your entities to start in the middle of the tile.

jstart  on October 8th, 2009

Would LOVE a tutorial on joystick implementation! I have been trying for weeks to get a good one setup, but to no avail! Please provide this to the community:)

Ralph  on October 8th, 2009

I think it would be a handy addition. I’ve contemplated using a joystick and two buttons to remake some old school arcade games but I was worried it would use up to much screen real estate. I would really like to see how you implemented this.

cybergreg  on October 8th, 2009

YES please a joystick tutorial would be EXCELLENT! Thanks

mike  on October 8th, 2009

Thanks for the feedback everyone. It certainly looks like it will be worth doing a tutorial on this. I am hoping that the implementation I have come up with for Sir Lamorak’s Quest will be useful to people. I’ve gone in a different direction from the code that was hidden inside Tutorial 10 which I was not happy with.

The new code is able to identify a touch on the joystick and then track that touch for as long as it lasts, moving around the sceen until it is released. While that touch is still going, the location of the players finger is used to calculate not only the angle the player should move but also the speed i.e. the further from centre you are the faster you can make the player move.

Whilst all this is going on any other taps are recognised as not belonging to the ongoing joystick movement and are handled as necessary i.e. firing a weapon.

I’ll get this tutorial started when I’m back in the UK and should have it up and ready by the weekend as I’m heading to Boston to present at the iPhone Developer Conference that weekend.

I’ll also try and post a small video of Sir Lamorak’s Quest so you can see how things are going with the game for the book. I’m just putting some graphics in place from the artist I’ve hired and its starting to look really cool :o)

Cheers

Mike

RoberRM  on October 8th, 2009

That sounds great! Thank you Mike for continue releasing your wonderful tutorials. ;)
i have one suggestion, though. I think I’m to the point where I could understand parts of your code on my own, without the need of a video-tutorial: is it appropriate if I ask for a more recent version of your code?

kakil  on October 9th, 2009

A joystick tutorial sounds great! I’d love to see it. It would be great to have a really useful tutorial like this to possibly use as a guide for implementing the same in my own games.

cutemachine  on October 11th, 2009

Hello Mike.

Yes, I would love to see a joystick tutorial. Keep up the great work. It really helps me to develop my skills.

Ant1  on October 12th, 2009

I am very interested it would be quite interesting to know how that could work for I’m still learning open GL ES

George  on October 13th, 2009

It’ll be great to see the Joystick Tut (And also some vids of the game).
Do you have an estimate, when we can purchase a Rough Cut of the book?
Regards

Simon  on October 24th, 2009

Hi Mike,

How’s the tutorial coming I’ve been checking in on a daily basis. Will their be a twitter update when it’s ready?

mike  on October 24th, 2009

Hi Simon

Its getting there. Slower than I wanted as seems to be the way with everything I touch at the moment, but there will be a twitter update :o)

Mike

Hen  on October 27th, 2009

Hi Mike,

I’ve started to read and watch your tutorials on the blog before 2 weeks ago, and i must to say that i’m learning a lot from every one of them. so keep that way :]

PS:
I tried to scroll a tiled map in Landscape mode, from right-to-left and all i got is from up-to-down (in landscape), what shold i do :/ ?

simon  on October 27th, 2009

@Hen

Have you tried setting it to up – down as surely that would get the desired outcome.

Simon

Romantech  on November 11th, 2009

Wow! I almost forgot about this site cause there have been no new tutorials. I just remembered it now that I was going through my bookmarks after installing Snow Leopard. You should really make more tutorials, they were awesome man…

John  on November 12th, 2009

Hi Romantech,

Mike is currently busy writing an iPhone Game Development book which is due out in Spring 2010. I have a few text tutorials lined up but recently moved house, so have no internet at home.

Normal service will be resumed soon! :)

jjack  on November 22nd, 2009

Hey guys,

Thank you for all the tutorials they really helped but I really need to implement a joystick in my game so can you get a tutorial up when you can. Thank You.

Also tutorial ten uses stuff that is deprecated so you might want to check that out.

Thank you guys for all your hard work

mike  on November 22nd, 2009

Hi Jack, I’m working on it and it should be up soon :o)

Mike

Benj  on November 23rd, 2009

Hi Mike, I’m very interesting by this tutorial and I’m very impatient to look it. May I have a date for the publication?

Thank for your jobs,
Benj.

mike  on November 23rd, 2009

Hi Benj

I have given dates before and the missed them :o(

Rather than do that again I can only say that I’m working it and I’m hoping to get it up as soon as possible, promise.

Mike

Leave a Comment