NEW TUTORIAL - How To Add A D Pad To Control Your Hero

It’s ridiculously simple and easy and I’m hoping it will help some of you out. Enjoy!

http://techority.com/2011/02/14/controlling-a-character-with-a-d-pad/

Peach :slight_smile: [import]uid: 10144 topic_id: 6529 reply_id: 306529[/import]

I just tweeted this @jametadeo

thanks for the new tut :smiley: [import]uid: 8045 topic_id: 6529 reply_id: 22897[/import]

You’re very welcome; it made me feel a bit better to write one again as I’ve been feeling a tad useless lately :wink:

Thanks so much for the tweet, most appreciated! [import]uid: 10144 topic_id: 6529 reply_id: 22918[/import]

Fantastic tutorial!

Thank you for creating such a useful and easy to understand tutorial, the notes really helped a lot.

Just a quick question.

How would i make the dpad only accept the touch input once?
At the moment the image is moving constantly when my finger is pressed down. I would like it only to move once, then move again with another press of the button. [import]uid: 24981 topic_id: 6529 reply_id: 23902[/import]

Just get rid of the enter frame event listener. [import]uid: 33866 topic_id: 6529 reply_id: 23926[/import]

It would also be possible to have arrow buttons that had something like;

function moveup (event)  
transition.to (hero, {time=1000, y=hero.y-50})  
end  
uparrow:addEventListener("tap", moveup)  

Something like that - I just woke up and am feeling a bit groggy, but I hope you get the idea.

Peach :slight_smile:

PS - Thanks so much for the kind words. Where are you from? I notice you spell “colour” the English way. [import]uid: 10144 topic_id: 6529 reply_id: 23997[/import]

Hey thanks for the help

Using “tap” works perfectly on the simulator however my phone doesnt recognise it, i have submitted it as a bug for now as it seems a bit strange.

btw im from London, England :slight_smile: [import]uid: 24981 topic_id: 6529 reply_id: 24032[/import]

Hey, no worries.

If tap isn’t working, try this instead;

function moveup (event) if event.phase == "ended" then transition.to (hero, {time=1000, y=hero.y-50}) end end uparrow:addEventListener("touch", moveup) [import]uid: 10144 topic_id: 6529 reply_id: 24040[/import]