Skip to main content
Participant
December 21, 2012
Question

Urgent help

  • December 21, 2012
  • 1 reply
  • 470 views

I have been trying to complete an assignment which is due 2mow.


We created a platform game which works on desktop with keyboard we now have to convert it to the mobile.


Can anyone help with script which I can place on button to


control a hero


1 walk right

2 walk left

3 jump


I have tried everything and just can not get it to work. have also tried accelerometer

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
December 21, 2012

btn_right.addEventListener(MouseEvent.MOUSE_DOWN,rightF)

btn_left.addEventListener(MouseEvent.MOUSE_DOWN,leftF);

btn_jump.addEventListener(MouseEvent.MOUSE_DOWN,jumpF);

and use the same listener functions you used with the keyboard to move right, left and jump

Participant
December 21, 2012

Do I place those on each button or in the main .as

I know I sound really thick about this

kglad
Community Expert
Community Expert
December 21, 2012

no code can be added to objects in as3 (and no code should be added to objects in as2) but exactly where you put that code, i can't say.

main.as sounds good but it needs to be in the same scope as your buttons and it needs to execute after the buttons exist.  and, that can't be determined from the info you've supplied.

but, if you already have working keyboardevent listeners controlling your character, it's reasonable to add that button code to the same place that you had your keyboardevent listeners and to have your buttons call those listener functions.