Be a Supporter!

walk control help

  • 300 Views
  • 8 Replies
New Topic Respond to this Topic
egoraptorfreak1
egoraptorfreak1
  • Member since: Jul. 28, 2008
  • Offline.
Forum Stats
Member
Level 07
Programmer
walk control help 2010-10-13 20:20:46 Reply

i need help with my walk code:

onClipEvent (load) { moveSpeed = 10;}onClipEvent (enterFrame) { if (Key.isDown(Key.RIGHT)) { this._x += moveSpeed;}}
onClipEvent (load) { moveSpeed = 10;}onClipEvent (enterFrame) { if (Key.isDown(Key.LEFT)) { this._x += moveSpeed;}}
onClipEvent (load) { moveSpeed = 10;}onClipEvent (enterFrame) { if (Key.isDown(Key.DOWN)) { this._y += moveSpeed;}}
onClipEvent (load) { moveSpeed = 10;}onClipEvent (enterFrame) { if (Key.isDown(Key.UP)) { this._y += moveSpeed;}}

when i press left he goes right and when i press right he goes right and when i press up he goes down and when i press down he goes down any help


WTF happend to Duke Nukem, Crash Bandicoot and Spyro?

BBS Signature
AntiAliasProductionz
AntiAliasProductionz
  • Member since: Apr. 20, 2008
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to walk control help 2010-10-13 20:25:43 Reply

At 10/13/10 08:20 PM, egoraptorfreak1 wrote: i need help with my walk code:

onClipEvent (load) { moveSpeed = 10;}onClipEvent (enterFrame) { if (Key.isDown(Key.RIGHT)) { this._x += moveSpeed;}}
onClipEvent (load) { moveSpeed = 10;}onClipEvent (enterFrame) { if (Key.isDown(Key.LEFT)) { this._x += moveSpeed;}}
onClipEvent (load) { moveSpeed = 10;}onClipEvent (enterFrame) { if (Key.isDown(Key.DOWN)) { this._y += moveSpeed;}}
onClipEvent (load) { moveSpeed = 10;}onClipEvent (enterFrame) { if (Key.isDown(Key.UP)) { this._y += moveSpeed;}}

when i press left he goes right and when i press right he goes right and when i press up he goes down and when i press down he goes down any help

You're gonna have to make it

onClipEvent (load) { moveSpeed = 10;}onClipEvent (enterFrame) { if (Key.isDown(Key.RIGHT)) { this._x += moveSpeed;}}
 onClipEvent (load) { moveSpeed = 10;}onClipEvent (enterFrame) { if (Key.isDown(Key.LEFT)) { this._x -= moveSpeed;}}
onClipEvent (load) { moveSpeed = 10;}onClipEvent (enterFrame) { if (Key.isDown(Key.DOWN)) { this._y -= moveSpeed;}}
onClipEvent (load) { moveSpeed = 10;}onClipEvent (enterFrame) { if (Key.isDown(Key.UP)) { this._y += moveSpeed;}}
AntiAliasProductionz
AntiAliasProductionz
  • Member since: Apr. 20, 2008
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to walk control help 2010-10-13 20:27:16 Reply

should explain what i did, right?

You were trying to get the character to move +x and +y for both key presses. You want to make it so that it subtracts x (-x) to go down and subtracts y(-y) to go left.

egoraptorfreak1
egoraptorfreak1
  • Member since: Jul. 28, 2008
  • Offline.
Forum Stats
Member
Level 07
Programmer
Response to walk control help 2010-10-13 20:30:38 Reply

omg thank you, im am very happy and will list you in the secondary thing when i submit this flash!


WTF happend to Duke Nukem, Crash Bandicoot and Spyro?

BBS Signature
egoraptorfreak1
egoraptorfreak1
  • Member since: Jul. 28, 2008
  • Offline.
Forum Stats
Member
Level 07
Programmer
Response to walk control help 2010-10-13 20:32:39 Reply

a u help me with one other thing plz i cant find a working tutorial for a hitTest any help?


WTF happend to Duke Nukem, Crash Bandicoot and Spyro?

BBS Signature
AntiAliasProductionz
AntiAliasProductionz
  • Member since: Apr. 20, 2008
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to walk control help 2010-10-13 20:37:29 Reply

At 10/13/10 08:32 PM, egoraptorfreak1 wrote: a u help me with one other thing plz i cant find a working tutorial for a hitTest any help?

Sure you've seen this, but this works.

AntiAliasProductionz
AntiAliasProductionz
  • Member since: Apr. 20, 2008
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to walk control help 2010-10-13 20:45:45 Reply

onClipEvent (load) { 
var moveSpeed = 10
if (Key.isDown(Key.RIGHT)) { this._x += moveSpeed;}
if (Key.isDown(Key.LEFT)) { this._x -= moveSpeed;}
if (Key.isDown(Key.DOWN)) { this._y -= moveSpeed;}
if (Key.isDown(Key.UP)) { this._y += moveSpeed;}
}

by the way, you don't need all the onClipEvents

egoraptorfreak1
egoraptorfreak1
  • Member since: Jul. 28, 2008
  • Offline.
Forum Stats
Member
Level 07
Programmer
Response to walk control help 2010-10-13 20:46:09 Reply

hate to bother you again but...i work in as2....


WTF happend to Duke Nukem, Crash Bandicoot and Spyro?

BBS Signature
MintPaw
MintPaw
  • Member since: Jun. 11, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to walk control help 2010-10-14 00:05:38 Reply

At 10/13/10 08:46 PM, egoraptorfreak1 wrote: hate to bother you again but...i work in as2....

This is all as2, it was just wrong.

onClipEvent (load) { 
var moveSpeed = 10
}
onClipEvent(enterFrame){
if (Key.isDown(Key.RIGHT)) { this._x += moveSpeed;}
if (Key.isDown(Key.LEFT)) { this._x -= moveSpeed;}
if (Key.isDown(Key.DOWN)) { this._y -= moveSpeed;}
if (Key.isDown(Key.UP)) { this._y += moveSpeed;}
}

If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.

BBS Signature