PDA

View Full Version : if statement help please



Dhryn
May 11th, 2006, 07:28 PM
I know this is possible, but I dont know how.

can some one please show me how to write an if statement so that if the character is in the top quater of the screen then something happens, I can write the then something happens part.

If possible would like it writen on a movie clip, so not in function form.

any help would be great.

DangerousDan
May 11th, 2006, 08:24 PM
uhh yeah rather easy actually...

onClipEvent(enterFrame){
if(this._y <= oneHalfOfScreen){ /* Replace oneHalfOfScreen with whatever half the height of the screen is...*/
Action Go here
}
}

That's for the top half the screen, the code goes in the movieclip. For one quarter of the screen just change the number to whatever.

Dhryn
May 11th, 2006, 08:47 PM
thankyou, I think there is a code 'function' thing that is designed for this job, I never thought of doing it like this, thank you very much. Do you want to be listed in the credits?

DangerousDan
May 11th, 2006, 09:35 PM
uhh, go ahead and add my name :player: I hope the game works out for you.

Joppe
May 12th, 2006, 08:38 AM
Dan, it will be much more easy to modify if you put


onClipEvent(enterFrame){
if(this._y <= Stage.height/2){
Action Go here
}
}

Inbuilt function yeh know :)

Dhryn
May 12th, 2006, 09:24 AM
thats the code I was talking about at the beginning, joppe I have already added your name and website to the credits, if you want them removing just say.

Thanks for your help

DangerousDan
May 12th, 2006, 12:39 PM
Yeah, I was too lazy to look it up and I've never used it (probably because I'm too lazy to look it up :bandit:) but yeah that's much easier.

Joppe
May 12th, 2006, 06:24 PM
Always use it Stage.height, Stage.width works like an charm :D