Elric
|
|
« on: Wednesday October 22, 2008, 02:50:33 am » |
|
Hey guys, I am using Macromedia Flash 8, which uses ActionScript 2.0
All I can do is get the character to move, I cannot get it to collide with platforms, it just falls straight through.
Help would be EXTREMELY appreciated.
|
|
|
|
|
raider00321
Moderator
King
Offline
Newgrounds Alias: raider00321
Posts: 969
Mood:Not a happy chappy
|
|
« Reply #1 on: Wednesday October 22, 2008, 02:54:21 am » |
|
Hey guys, I am using Macromedia Flash 8, which uses ActionScript 2.0
All I can do is get the character to move, I cannot get it to collide with platforms, it just falls straight through.
Help would be EXTREMELY appreciated.
alright! help is what i want to give you! but need a bit more information. For instance, Could i please see the script your using hitTest as?
|
|
|
|
Elric
|
|
« Reply #2 on: Wednesday October 22, 2008, 02:58:33 am » |
|
onClipEvent(load){ falling = true; } onClipEvent(enterFrame){ if(falling = true){ this._y += 5; }else{ this._y += 0; } if(Key.isDown(RIGHT)){ this._x += 5; } if(Key.isDown(LEFT)){ this._x -= 5; } if (_root.ground.hitTest(this._x, this._y, true)) { falling = false; } }
(This is in a MovieClip called char, and there is another MovieClip called ground) (Keep in mind I'm know basically nothing xD)
|
|
|
|
raider00321
Moderator
King
Offline
Newgrounds Alias: raider00321
Posts: 969
Mood:Not a happy chappy
|
|
« Reply #3 on: Wednesday October 22, 2008, 03:18:04 am » |
|
onClipEvent(load){ falling = true; } onClipEvent(enterFrame){ if(falling = true){ this._y += 5; }else{ this._y += 0; } if(Key.isDown(RIGHT)){ this._x += 5; } if(Key.isDown(LEFT)){ this._x -= 5; } if (_root.ground.hitTest(this._x, this._y, true)) { falling = false; } }
(This is in a MovieClip called char, and there is another MovieClip called ground) (Keep in mind I'm know basically nothing xD)
hmmm.... First of all... I'm not too sure you need the true statement Anyway, make sure the instance name of ground is ground. as for this._x and so on. try to fix it up with giving it a direct path such as _root.char._x and so on... if that doesn't work,l do you mind if you upload the fla file somewhere for me to check it?
|
|
|
|
|
raider00321
Moderator
King
Offline
Newgrounds Alias: raider00321
Posts: 969
Mood:Not a happy chappy
|
|
« Reply #5 on: Wednesday October 22, 2008, 03:28:41 am » |
|
no, not at all. like i said, they didnt have an instance name. No biggie and very easy to forget to do :p Doesnt matter for the char as much, but prolly best to give it the right name.. Ok.. so heres what you need to do... 1. Click on the ground movieClip, then where click on properties. 2.Once there you will see a white box with instance name in it. in that white box, give it the instance name ground. YOu might want to do a similar thing with the char movieclip cept you would give it the instance name char. Hope this helps
|
|
|
|
raider00321
Moderator
King
Offline
Newgrounds Alias: raider00321
Posts: 969
Mood:Not a happy chappy
|
|
« Reply #6 on: Wednesday October 22, 2008, 03:34:21 am » |
|
actually, that wasnt the only problem lol. there were also problems with your code... ill post the proper code here in just a moment lol
|
|
|
|
Elric
|
|
« Reply #7 on: Wednesday October 22, 2008, 03:38:14 am » |
|
Ohhh! Instance name is in properties, i thought it was just what you called the movieclip, thanx
|
|
|
|
raider00321
Moderator
King
Offline
Newgrounds Alias: raider00321
Posts: 969
Mood:Not a happy chappy
|
|
« Reply #8 on: Wednesday October 22, 2008, 03:40:56 am » |
|
ok.. here it is onClipEvent(load){ falling = true; } onClipEvent(enterFrame){ if(falling == true){/*notice the two equals signs. Remember, one equal sign is used for assigning values, two equals signs checks variables values for equivilency and three equal signs checks variables for strict equivilency*/ this._y += 5; }else{ this._y += 0; } if(Key.isDown(RIGHT)){ this._x += 5; } if(Key.isDown(LEFT)){ this._x -= 5; } if (this.hitTest(_root.ground)) {//ok, i moved this around a bit. what you had before wasn't really needed falling = false; } }
Im not 100% sure, but i think you may have some problems with your movement script too..
|
|
|
|
raider00321
Moderator
King
Offline
Newgrounds Alias: raider00321
Posts: 969
Mood:Not a happy chappy
|
|
« Reply #9 on: Wednesday October 22, 2008, 03:47:28 am » |
|
yep, like i thought, you will have movement issues. you will need to use this to fix it instead of yours if (Key.isDown(Key.LEFT)) { _x -= 5; }
|
|
|
|
Elric
|
|
« Reply #10 on: Wednesday October 22, 2008, 03:53:33 am » |
|
*Praises*
You have NO idea how much you just helped me xD THANX
|
|
|
|
raider00321
Moderator
King
Offline
Newgrounds Alias: raider00321
Posts: 969
Mood:Not a happy chappy
|
|
« Reply #11 on: Wednesday October 22, 2008, 04:00:15 am » |
|
haha no problem. if you need anymore help, feel free to drop by
|
|
|
|
|
|