Be a Supporter!

position problem

  • 577 Views
  • 13 Replies
New Topic Respond to this Topic
up-a-notch
up-a-notch
  • Member since: Sep. 29, 2009
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
position problem 2010-02-18 19:36:00 Reply

I need to make it so my guy faces the same way when you let go of the key

code 1:

code 2: onClipEvent (enterFrame) {
if (!Key.isDown(Key.LEFT)) {
this._y -= speed;

this.gotoAndStop(1);

} else {
this.play();
}
}

swf: http://www.newgrounds.com/dump/item/d5ef de373995266c401cd5d71a700c09 (arrow keys to move)


Bipolar Smiley: (:(

BBS Signature
CrustySheet
CrustySheet
  • Member since: May. 3, 2006
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to position problem 2010-02-18 19:59:11 Reply

At 2/18/10 07:36 PM, up-a-notch wrote: I need to make it so my guy faces the same way when you let go of the key

code 1:

code 2: onClipEvent (enterFrame) {
if (!Key.isDown(Key.LEFT)) {
this._y -= speed;

this.gotoAndStop(1);

} else {
this.play();
}
}

swf: http://www.newgrounds.com/dump/item/d5ef de373995266c401cd5d71a700c09 (arrow keys to move)

you needto lookinto _xscale

you wantto change it

_xscale = 100
_xscale = -100

stuff likethat in left and right

up-a-notch
up-a-notch
  • Member since: Sep. 29, 2009
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to position problem 2010-02-18 20:09:42 Reply

this happened! http://www.newgrounds.com/dump/item/2847 d9be9361ae7dc8d87f8072daf0ed


Bipolar Smiley: (:(

BBS Signature
Archawn
Archawn
  • Member since: Sep. 9, 2007
  • Offline.
Forum Stats
Member
Level 27
Game Developer
Response to position problem 2010-02-18 21:16:52 Reply

At 2/18/10 07:36 PM, up-a-notch wrote: I need to make it so my guy faces the same way when you let go of the key

What do you mean? Could you maybe make an example or explain that more thoroughly? It's hard to know what you're having problems with.

Also, post all relevant code that would be useful in fixing your problem. You should use code tags as well.

position problem

up-a-notch
up-a-notch
  • Member since: Sep. 29, 2009
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to position problem 2010-02-19 11:40:41 Reply

ok here

code on guy:

onClipEvent (load) {
	speed = 10;
}
onClipEvent (enterFrame) {


	if (Key.isDown(Key.RIGHT)) {
		this._x += speed;
		

		this.gotoAndStop(3);
	}
	if (Key.isDown(Key.LEFT)) {
		this._x -= speed;
		
		this.gotoAndStop(2);
	}

	if (Key.isDown(83)) {
		this.gotoAndStop(4);
	}
	if (Key.isDown(65)) {
		this.gotoAndStop(5);
	}

	if (Key.isDown(68)) {
		this.gotoAndStop(6);
	}
	if (Key.isDown(Key.DOWN)) {

		this.gotoAndStop(8);
	}

	if (Key.isDown(83)) {
		this.gotoAndStop(4);
	}


}

codes inside guy:

code 1:

onClipEvent (enterFrame) {
	if (!Key.isDown(Key.LEFT)) {
		this._y -= speed;
		_xscale = -100;


		
	} else {
		this.play();
	}
}

code 2:

onClipEvent (enterFrame) {
	if (!Key.isDown(Key.RIGHT)) {
		this._y -= speed;
		_xscale = 100;

	} else {
		this.play();
	}
}

Bipolar Smiley: (:(

BBS Signature
up-a-notch
up-a-notch
  • Member since: Sep. 29, 2009
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to position problem 2010-02-19 14:07:31 Reply

help me :(


Bipolar Smiley: (:(

BBS Signature
up-a-notch
up-a-notch
  • Member since: Sep. 29, 2009
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to position problem 2010-02-21 14:06:52 Reply

bump


Bipolar Smiley: (:(

BBS Signature
TheSongSalad
TheSongSalad
  • Member since: Jan. 17, 2009
  • Offline.
Forum Stats
Member
Level 19
Audiophile
Response to position problem 2010-02-21 14:36:44 Reply

i don't even understand what you want still. could you explain what your asking better?

up-a-notch
up-a-notch
  • Member since: Sep. 29, 2009
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to position problem 2010-02-21 14:56:25 Reply

when you let go of moving the guy faces right so it is a problem if you are running left


Bipolar Smiley: (:(

BBS Signature
up-a-notch
up-a-notch
  • Member since: Sep. 29, 2009
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to position problem 2010-02-21 21:30:01 Reply

bump


Bipolar Smiley: (:(

BBS Signature
NsNr8r
NsNr8r
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to position problem 2010-02-21 23:05:01 Reply

logically.. you probably want to set a facing direction for your character, so when you let go of an arrow key, you know which direction he was walking last. I use 0, 1, 2, 3... left up right down.

when the key is up, you gotoAndStop(IDLE_DIRECTION); simple AS pie... lol... AS

up-a-notch
up-a-notch
  • Member since: Sep. 29, 2009
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to position problem 2010-04-19 23:35:14 Reply

it says it has errors!

onClipEvent (load) {
	speed = 10;
}
onClipEvent (enterFrame) {


	if (Key.isDown(Key.RIGHT)) {
		this._x += speed;


		this.gotoAndStop(3);
	}
	if (Key.isDown(Key.LEFT)) {
		this._x -= speed;

		this.gotoAndStop(2);
	}
	if (Key.isToggled((Key.LEFT)) {
		gotoAndStop(IDLE_DIRECTION);
	}
	if (Key.isToggled((Key.RIGHT)) {
		gotoAndStop(IDLE_DIRECTION);
	}
	if (Key.isDown(83)) {
		this.gotoAndStop(4);
	}
	if (Key.isDown(65)) {
		this.gotoAndStop(5);
	}

	if (Key.isDown(68)) {
		this.gotoAndStop(6);
	}
	if (Key.isDown(Key.DOWN)) {

		this.gotoAndStop(8);
	}

	if (Key.isDown(83)) {
		this.gotoAndStop(4);
	}


}

onClipEvent (enterFrame) {
	if (jumping) {
		_y += jumpspeed;
		jumpspeed += 1;
		if (_y>=y_start) {
			_y = y_start;
			jumping = false;
		}
	} else {
		if (Key.isDown(Key.SPACE)) {
			jumping = true;
			jumpspeed = -14;
			this.gotoAndStop(7);
		}
	}
}

Bipolar Smiley: (:(

BBS Signature
Treerung
Treerung
  • Member since: Apr. 18, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to position problem 2010-04-20 15:34:23 Reply

Just have the character face the same way for both moving right and left and use _xscale to determine which direction you face.

onClipEvent (enterFrame) {
 
 
 	if (Key.isDown(Key.RIGHT)) {
 		this._x += speed; 
               this._xscale=100
 		this.gotoAndStop(3);
 	}
 	if (Key.isDown(Key.LEFT)) {
 		this._x -= speed;
                this._xscale=-100 
 		this.gotoAndStop(3);
	}
}

:'(

BBS Signature
up-a-notch
up-a-notch
  • Member since: Sep. 29, 2009
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to position problem 2010-04-20 18:01:44 Reply

look what happens: http://www.newgrounds.com/dump/item/a2d8 e1eaaea8306768730ca01fb96c70


Bipolar Smiley: (:(

BBS Signature