Ytrr
20 posts
|
I’m making my first game in Flash, a maze game. In CS4, AS2.
At the moment I’ve got a game with 2 levels, if you come to the finish, you go to level 2 and if you hit the wall you go to a “Play again” keyframe.
I also have made a anti-rightclick-cheat thingy and disabled TAB.
But I want to know some things:
I want that if I hit the finish, I go to an “next level” keyframe (that works already), and then to the next level. But I can’t figure out how. I tried:
on(release){
nextFrame();
}
But then it always goes to the same level…
And also, you can still cheat with the left mousekey; how to disable this? I don’t want to disable the whole left-click or get a “cheater” screen when you hit it because then the buttons ‘play again and next elvel’ won’t work.
And at last I want to, if you move to the next level; that your mouse position is setted to a certain position (like (5,5) or something).
Tnx. if anybody can help me!!!
|
|
|
Devlini
176 posts
|
You cant set a mouse position that I know about and cant you just use:
on(release){
gotoAndPlay(2);
}
|
|
|
Ytrr
20 posts
|
Why (2)? That is the play again frame.... And I want this:
(level1)-----(finish)->(next level frame)---(click on "next level" button)->(level2)-----(finish)->(next level frame)---(click on "next level" button)->(leve3)-----(finish)->(next level frame)---(click on "next level" button)-> (...) -> (winning screen).
Oh, and I have another question. I've got now 6 keyframes. Is it possible to insert a new keyframe at the beginning from the clip (or between two others keyframes), for a menu or something else?
|
|
|
Devlini
176 posts
|
Just change the number 2 to whatever frame you want it to take you to.
You can move the frames along one by copying and pasting then editing the first frame to become a menu.
|
|
|
Ytrr
20 posts
|
1. Yes I know that but i want to take it to the next level. I only have one NEXT LEVEL keyframe, and I want it to go every time to the next level.
2. How can I do that than (I know Ctrl+C and Ctrl+V). HOw does that work??
|
|
|
Devlini
176 posts
|
1. The way you said you tried should work and I don’t understand why it doesnt. Have you got a frame after the one with this code in?
on (release) {
nextFrame();
}
2. highlight which frames you need to move in the frame window and then right click and copy then right click where you want to move them and paste.
|
|
|
Supersausagedog
51 posts
|
If you want one frame to do all of it then you want to set a variable when you win which says the next frame to go to, then go to the NEXT LEVEL keyframe and then in the button put
on(release){
gotoAndStop(_root.nextlevel)
}
and when you win a level put
var nextlevel = insert what level comes next after the NEXT LEVEL keyframe
|
|
|
shittasticf
3 posts
|
Every time I see a post with “keyframe” in it I die a little inside.
|
|
|
Osiris602
81 posts
|
just for the record i dont believe that you can change the persons mouse pointer so it would be better just to make the start where the maze before it ends
|
|
|
Ytrr
20 posts
|
OK thanks. Copying works. Next level works. But I want to know one thing:
AFAIK is only one cheat methoid left: dragging. How can I fix this? I’ve allready tried.
[code] on(dragOver){
gotoandstop(2);
} [/code]
But it didn’t work. Can you help me?
|
|
|
Ytrr
20 posts
|
I mean
[pre]
on(dragOver){
gotoandstop(2);
}
[/pre]
|
|
|
Ytrr
20 posts
|
Or (sorry for dubbledubblepost)
on(dragOver){
gotoandstop(2);
}
|
|
|
saybox
140 posts
|
That would be a triple post :P
If you’re hit testing against the mouse its impossible to prevent glitching entirely; I guess one thingyou could do wout be to make an invisible button below the ones that need to be clickable (so that if you click anything apart from them, you’ll press the invisible one. However this won’t stop mouse jumping and as far as i know there’s no way to prevent that unless you haev a mouse follower.
Invisible waypoints would help a little too though.
Also frames for this sort of thing are somethign to be avoided, for best practice. it’s not realyl a big deal though :)
|
|
|
boxmein
6 posts
|
The easiest way to make a maze NOT be able to left-click cheat is to make a small dot then make it a MovieClip, reg point center and enter THIS code :
x = _mousex
_y = _mousey
Mouse.hide();
onClipEvent(enterFrame) {
if(root.wall.hitTest(_x, _y, true)) {
_root.gotoAndStop(1)
}
}
The first 2 lines will make the clip follow the mouse
The 3rd line makes the mouse hidden
The last part does : if you touch the wall instanced movieclip by its reg. point, the main frame goes to 1.
|
|
|
boxmein
6 posts
|
Originally posted by boxmein:
The easiest way to make a maze NOT be able to left-click cheat is to make a small dot then make it a MovieClip, reg point center and enter THIS code :
x = mousex
_y = _mousey
Mouse.hide();
onClipEvent(enterFrame) {
if(root.wall.hitTest(x, _y, true)) {
_root.gotoAndStop(1)
}
}
The first 2 lines will make the clip follow the mouse
The 3rd line makes the mouse hidden
The last part does : if you touch the wall instanced movieclip by its reg. point, the main frame goes to 1.
Sorry for db but that is _x on the first line.
|
|
|
Ytrr
20 posts
|
So then I have to change _root.gotoAndStop(1) into the “game over” frame? But… if(root.wall.hitTest(x, _y, true)) { if my isn’t called “wall” I need to change it? But i make a wall seperately for each level. How does that work then? Or do I need to change that?
(Lots of questions, I know…)
|
|
|
Ytrr
20 posts
|
The code doesn’t work. Or I did something wrong. I made a small thingy, converted it into a movieclip and added the code to it. But there came all kind of errors:
Error Scene=Scene 1, layer=Layer 1, frame=1, Line 1: Statement must appear within on/onClipEvent handler
x = mousex
Error Scene=Scene 1, layer=Layer 1, frame=1, Line 3: Statement must appear within on/onClipEvent handler
_y = _mousey
Error Scene=Scene 1, layer=Layer 1, frame=1, Line 5: Statement must appear within on/onClipEvent handler
Mouse.hide();
Error Scene=Scene 1, layer=Layer 1, frame=1, Line 9: ‘)’ expected
if(root.Level 1.hitTest(x, _y, true)) {
Error Scene=Scene 1, layer=Layer 1, frame=1, Line 11: Statement must appear within on/onClipEvent handler
_root.gotoAndStop(2)
Error Scene=Scene 1, layer=Layer 1, frame=1, Line 13: Unexpected ‘}’ encountered
}
Total ActionScript Errors: 6, Reported Errors: 6
|
|
|
Ytrr
20 posts
|
O yeah.. And my wall thing is not a Movieclip but a button… And I make them seperately for each level….
|
|
|
Ytrr
20 posts
|
Very sorry for my quadruple post but my problem is not yet solved…
|
|
|
MaToMaStEr
38 posts
|
mmm what about… making the player have to CLICK an DRAG certain object through the maze. That way you could avoid some “cheats”… when the player release the button you stop dragging the object. The same should happen when you move the mouse off the screen.
|
|
|
Ytrr
20 posts
|
hm.. Good idea!! ( but how can I do that)
|
|
|
MaToMaStEr
38 posts
|
well,,, suposing the movieClip to be dragged has an instance name of “dragMe”:
dragMe.onPress = function(){
this.startDrag();
}
dragMe.onRelease = function(){
this.stopDrag();
}
About the actions when the mouse leave the Stage…. you should add a MouseListener:
var myMouseLis:Object = new Object();
Mouse.addListener(myMouseLis);
myMouseLis.onMouseMove = function(){
if(_xmouse<0 || _xmouse>Stage.width || _ymouse<0 || _ymouse>Stage.height) dragMe.stopDrag();
}
I havent tried it myself but… i think it should work.
You can then detect collisions on the dragMe.onEnterFrame function.
|
|
|
Ytrr
20 posts
|
And where do I need to enter this codes?
|
|
|
MaToMaStEr
38 posts
|
on a frame of the main timeLine…. remember that that code sould work, assuming the movieclip to be dragged has an instance name of “dragMe”
Also, remember to check for collisions between dragMe and your maze on the onEnterFrame method for dragMe
|
|
|
Ytrr
20 posts
|
On my first frame (where the dragMe is in) I pasted this code. It looked like this:
dragMe.onPress = function(){
this.startDrag();
}
dragMe.onRelease = function(){
this.stopDrag();
}
var myMouseLis:Object = new Object();
Mouse.addListener(myMouseLis);
myMouseLis.onMouseMove = function(){
if(_xmouse<0 || _xmouse>Stage.width || _ymouse<0 || _ymouse>Stage.height) dragMe.stopDrag();
}
}
stop();
function onEnterFrame()
{
if(Key. (and so on)
But it doesn’t work. And what do you mean with:
“Also, remember to check for collisions between dragMe and your maze on the onEnterFrame method for dragMe” ??
|