Jump to content

HTML5/JS Touch Player Navigation (Up/Down) & Shooter Control?


p1nesap
 Share

Recommended Posts

Would like to port my HTML5 arcade game which uses arrows for player navigation and space key to shoot, to Android via XDK. 

 

I had success with this basic demo, built .apk with XDK and installed on my 'Droid, showing the coordinates of a rectangle using touch. So that's a start. 

 

But how are you guys implementing player navigation and shooting? Is there a doc/tutorial? This dev has a controller library on github—that's all I'm finding. Thanks in advance for direction. 

Link to comment
Share on other sites

You can use virtual controls to handle both movement and shooting.

It's basically one sprite (or two) that will be used by the user to control the game.

This approach is very common (my games ported from flash to Android use them).

An alternative is to detect if user clicked at left/right/up/down side of your sprite and move it in that direction. For shooting a click over it should do the trick.

Another alternative is to use accelerometer to move sprite and let user click in any place in the screen to shoot (except when clicking in a control like sound on/off).

Link to comment
Share on other sites

Thanks for replying plicatibu. So I make directional sprite to move player, and sprite button to shoot. Please link to code sample or tutorial how to implement touch with sprites, that control other sprites (not just move 1 sprite around with finger, which is all I know how to do at this point). 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...