PDA

View Full Version : rpg - moving between screens



Dhryn
March 9th, 2006, 11:17 AM
I am new to action script, and I have started to make a RPG, not the easiest thing to do but never mind.
I have so far made the following:

Preloader
Name Entry
Moving Character with animation
Attack with animation (bad animation)
stop at the side of the screen
stop on certain objectsI am now trying to make it so that my character hits a doorway and moves to the next screen, however I want to be able to make several entrances/exits to the rooms and so I want the program to know for which entrance to entre the character.

I have searched the tutorials but was unable to find much to help.

I did find some one else with the same problem but I didnt understand the solution and I dont want to copy some one elses work plus the thread start about two years ago so I cant ask anyone in that thread.

Any help would be greatly appreciated

Joppe
March 9th, 2006, 01:30 PM
Well make a variable then check


if(varname = 1){
this._x = 20;
this._y = 50;
}else{
if(varname = 2){
this._x = 70;
this._y = 20;
}
}

get it?

Dhryn
March 9th, 2006, 01:58 PM
so do I give the corisponding doors the same variable, then enter the possition of the variable/door and the character will appear there.
Where do I place the code, I am guessing in the main frame.

Joppe
March 9th, 2006, 02:02 PM
In the hittest code you have like


if(this.hitTest(door1)){
varname = 1;
_root.gotoAndStop(frame);
}

then on the frame you have the code i posted above.. Understand?

Dhryn
March 9th, 2006, 02:12 PM
I believe I do, Thank you very much for your help.

If I have any more problems with this then I will carry on this post, if possible could you check it in the next day or two for me.

Thank you

Joppe
March 9th, 2006, 02:31 PM
Of course, hope it works out for you :)

Dhryn
March 9th, 2006, 02:42 PM
I have been unsuccesful when entering your code, I dont think I understood properly, I have a lot of code laying about everywhere because I am just learning and so I have taken bits of code from everywhere and tried to change them to fit my game.

Would it be easier for me to post a copy of my game so you can look at it and explain to me dirrectly to my game.

Or if you made a simple game that demonstrates your coding so that I can atempt to olter it to mine.

sammi
March 9th, 2006, 05:12 PM
I had the same question on my mind but try this code
on your character MC.
onClipEvent (enterFrame) {
if (this.hitTest(_root.Teleport)) {
_root.gotoAndPlay();
}
}

Make a MC, name it door and its variable name Teleport.
and on gotoandplay put in the frame watever your next room would be in.

Dhryn
March 9th, 2006, 05:23 PM
I have tried this, I am using scenes in my game so that I could easily make an preloader.
The games itself is all in the smae scene, how do I make it go to frame 2 in scene 1.

bombsledder
March 9th, 2006, 07:31 PM
don't use scenes, it's too buggy ( but your choice i guess ),

i would do this,


function teleport(frame){gotoAndStop(frame)}


with this,


if(_root.hero.hitTest(_root.door)){teleport(_root. door.tp)}


and on the door you want just set "tp" to what ever frame you wan't it to be in

@joppe why would you add the extra variable in for the checking o.O

nathan99
March 10th, 2006, 07:05 AM
@bombsledder

not many beginners can use that method, give them a shot, and some credit for trying. Just post another way, let them figure for themselves when they want to;) I mean that in a non-offensive way, i love you, in a non-cyer, weird screwed up way :ne:

BTW: Use the [code] tags;)

bombsledder
March 10th, 2006, 09:42 AM
I guess but it kind of helps to learn functions early on, instead of relying on ifs/else for every little thing (and using AS1), using AS1 then jumping to AS2 what a big leap but makes coding so much easier, thats why i posted my code in AS2 and now AS1



function teleport(frame){gotoAndStop(frame)}

if(_root.hero.hitTest(_root.door)){teleport(_root. door.tp)}

Dhryn
March 10th, 2006, 12:10 PM
Thankyou for your replys.

I am a combination of NOOOB and thick which doesnt help, I am going to get rid of the scenes.

Can you tell me which code would work best from many doors ( looking at 100's), and how to use it, like were to place it.

thankyou for your help

bombsledder
March 10th, 2006, 04:37 PM
for 100's of doors, Mine would probably be the best for your situation, and every door you load has to tell what frame you want to goto, or you could change my function to



function teleport(x:Number,y:Number){_root.hero._x=x,_root. hero._y=y}

if(_root.hero.hitTest(_root.door)){
teleport(_root.door.tp.x,_root.hero.tp.y);
}

//door
door.tp={x:50,y:100}


and when the hero hits the door he will automaticaly teleport to the cordinates, or you could use the one i posted before, or** you could combine then and make a better function