Welcome Guest [Log In] [Register]
Welcome to Brackenwood. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
My game; please help
Topic Started: Feb 12 2006, 08:58 PM (332 Views)
flash_bass
Member Avatar
Brackenwood Lightweight
I am making a game at the moment and there are a few things i will need help with but ill post them in segments . new segments will apear once i fix the last problem. please help ill be greatfull and you name will go in the credits.


[size=7]1st segment:[/size]

i have some script to make a guy walk, stand on platforms and not go throu walls the thing is this script will only work once i export it as a flash 6 file not allowing me to add certian new fetures... is there a way to convert the script so it'l work in flash 8 without any (or few) changes...


thank you :)

from kieran



heres the script


on the character ive got
Code:
 
onClipEvent (load) {
gravity = 10;
scale = _xscale;
walkSpeed = 6;
maxjump = 6;
}
onClipEvent (enterFrame) {
if (air == true) {
 _y += gravity;
 state = 3;
}
if (Key.isDown(Key.LEFT) && !_root.leftbound.hitTest(_x, _y, true)) {
 _x -= walkSpeed;
 _xscale = -scale;
}
if (Key.isDown(Key.RIGHT) && !_root.rightbound.hitTest(_x, _y, true)) {
 _x += walkSpeed;
 _xscale = scale;
}
if (_root.platforms.hitTest(_x, _y, true)) {
 air = false;
} else {
 air = true;
}
if (Key.isDown(Key.SPACE) && jump == true) {
 _y -= jumpSpeed;
}
if (air == false) {
 jump = true;
 jumpcount = 0;
 jumpSpeed = 22;
}
if (Key.isDown(Key.SPACE)) {
 jumpcount += 1;
}
if (jumpcount > maxjump && jumpSpeed > -2) {
 jumpSpeed -= 2;
}
if (air == false && !Key.isDown(Key.LEFT) && !Key.isDown(65) && _currentframe < 4 or air == false && !Key.isDown(Key.RIGHT) && !Key.isDown(65) && _currentframe < 4) {
 state = 1;
}
if (Key.isDown(Key.LEFT) && air == false && !Key.isDown(65) && _currentframe < 4 or Key.isDown(Key.RIGHT) && air == false && !Key.isDown(65) && _currentframe < 4) {
 state = 2;
}
if (!Key.isDown(65)) {
 gotoAndStop(state);
}
_root.statetxt = state;
}
onClipEvent (keyUp) {
if (Key.getCode() == 83) {
 jump = false;
}
}
{



on the ground the instance name is PLATFORMS
and ive got this script on them
Code:
 
onClipEvent (enterFrame) {
if (_root.deathTrap.hitTest(_x,_y,true)) {
 gotoAndStop(deathFrame);
}
}



and there are two walls with the instance name of rightbound and leftbound
they have no script
Offline Profile Quote Post Goto Top
 
smoscar_01
Member Avatar
Mid-Level ActionScripter
it should work perfectly published on flash 8 (just erasing the last '{' on the character code) and maybe adding this

Code:
 
...
if (_root.platforms.hitTest(_x, _y+ (this._height)/2 , true)) {
air = false;
} else {...


this way you can get a lot of control of your character position in further things without moving the pivot position of the object
Offline Profile Quote Post Goto Top
 
flash_bass
Member Avatar
Brackenwood Lightweight
nah it doesnt work he just falls straight through the ground
Offline Profile Quote Post Goto Top
 
smoscar_01
Member Avatar
Mid-Level ActionScripter
did you erase the last '{' ?

Code:
 

...

onClipEvent (keyUp) {
if (Key.getCode() == 83) {
jump = false;
}
}
{  //You need to erase this line


I already give it a try, maybe its a name recognition problem for example plaform instead of platform :)
Offline Profile Quote Post Goto Top
 
pez
Brackenwood Lightweight
make sure you name/refer to everything correctly. naming is case sensitive, so if, for example, your movie clip's called "Platforms", referring to is as "platforms" wouldn't work.
Offline Profile Quote Post Goto Top
 
flash_bass
Member Avatar
Brackenwood Lightweight
ahhh none of these have worked. thanks for the help. the thing is it works when i export it as flash 6 but when i try flash 8 my character just falls throught the ground :o
Offline Profile Quote Post Goto Top
 
smoscar_01
Member Avatar
Mid-Level ActionScripter
look heres the game so far...it still has a lot of errors but heey maybe they'll be fixed in further segments :lol:



NOTE: Ive already sent the fla file to your email (click the game screen to play it)

(TIPS: add a mask to the character and the collision must be just with the feet and the platform ;) )
Offline Profile Quote Post Goto Top
 
flash_bass
Member Avatar
Brackenwood Lightweight
Yes yes yes i figured out what was rong
in flash 6 the action script mussent be case sensative and i didnt think to change it when i exported as 8 but i did and it worked yes thanks for you help smoscar and pez
Offline Profile Quote Post Goto Top
 
flash_bass
Member Avatar
Brackenwood Lightweight
now i need hittest i need a movie clip to take my character to another frame
but it will only work when youve got the amount of apples in the level and if you dont and try to go through itl desplay a message :blink: is this possible
Offline Profile Quote Post Goto Top
 
smoscar_01
Member Avatar
Mid-Level ActionScripter
yes it is possible, Ill give you some tips for you to experiment with them alright?

you can declare a counter variable

Code:
 
counter=0;


and each time an apple is eaten youll have to do something like this

Code:
 
counter++; //this code its the same than this counter=counter+1;


now when your character touches the exit movieclip it will only let you out IF the counter equals the amount of apples needed :) but IF not then you can adjust the properties _x and _y of an alert movieclip :P
Offline Profile Quote Post Goto Top
 
flash_bass
Member Avatar
Brackenwood Lightweight
:gasp: im no action scripter ive already got my apples action script mayb i should send the fla over msn what time do u come on smoscar
Offline Profile Quote Post Goto Top
 
smoscar_01
Member Avatar
Mid-Level ActionScripter
you say the time or send it to smoscar.01@gmail.com Ive got a lot of available space there :lol:

maybe we could set a time for a step by step helpy tutorial :lol:
Offline Profile Quote Post Goto Top
 
flash_bass
Member Avatar
Brackenwood Lightweight
yeah sounds great im usaly on from 6 to 8 austalian perth time i dono what that is compered to where ever you live :blink: ill email you the fla so you can have a look any way

thank you
Offline Profile Quote Post Goto Top
 
crumb
Rufum Ru Sudily!
likeing it Kerien, can't wait for the finished product :)
Offline Profile Quote Post Goto Top
 
smoscar_01
Member Avatar
Mid-Level ActionScripter
ok those are 7 hours of difference, you say the time, and I didnt recieved your mail :blink:
Offline Profile Quote Post Goto Top
 
smoscar_01
Member Avatar
Mid-Level ActionScripter
ok Ive already received it, but just the swf file :blink: well it doesnt really matters

what you have to do is get a var named counter and another for the total amount of apples at the first frame code, something like this:

Code:
 
var counter:Number=0;
var tapples:Number=3;


then youll have to add 1 to counter everytime an apple is eaten: (this code would have to be at the apple code)

Code:
 
if (this.hitTest(character)){
_root.counter +=1;
}


and finally youll have to ask, when the character 'hits' the warp object, if he can continue (this code needs to be at the exit code), lets say you also draw an alert box with the message 'Not enough apples' and link it to ActionScript

Code:
 
if (this.hitTest(character)){
if (_root.counter == _root.tapples)
  gotoAndPlay('Next');
}
else{
  _root.attachMovie("mysign", "sign" ,0);
 sign._x = Stage.width / 2;
 sign._y = Stage.height / 2;
 erasecount=0
 _root.onEnterFrame = function() {
   erasecount ++;
   if (erasecount == 100){
     removeMovieClip(sign);
     _root.onEnterFrame=null;
   }
 }
}
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Actionscript · Next Topic »
Add Reply