Forum Topic: How To Flip Enemy To Face Player

(71 views • 2 replies)

This topic is 1 page long.

<< < > >>
None

rishabh005

Reply To Post Reply & Quote

Posted at: 5/11/08 03:42 AM

rishabh005 DARK LEVEL 08

Sign-Up: 02/08/08

Posts: 144

Hi , Newgrounders ..

I wanna Know that What I should Apply to Enemy MC , So he Could Face the Player MC By flipping Horizontally ?? I mean only Two Directions East And West.


None

Coaly

Reply To Post Reply & Quote

Posted at: 5/11/08 03:48 AM

Coaly FAB LEVEL 21

Sign-Up: 08/11/04

Posts: 2,622

The usual way this is done is by changing the _xscale of the enemy. If your enemy is originally facing to the right, when he's facing to the right his _xscale is 100, and when he's facing to the left his _xscale would be -100, assuming you didn't scale him at all. So you could use an if statement to test if the player is on the left or right of the enemy, and then change the _xscale of the enemy accordingly.

if(enemy._x < player._x){
enemy._xscale = 100;
}else{
enemy._xscale = -100;
}

for example...

Error

BBS Signature

None

rishabh005

Reply To Post Reply & Quote

Posted at: 5/11/08 03:56 AM

rishabh005 DARK LEVEL 08

Sign-Up: 02/08/08

Posts: 144

Oo , Thanks that Worked ,,
Thank You Very much


All times are Eastern Standard Time (GMT -5) | Current Time: 04:16 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!