-
1. Re: How to make maze walls?
kglad Jun 17, 2012 8:59 AM (in response to Tixzy)1 person found this helpfulif each wall is a rectangle, you can simplify your coding by creating a parent for the walls and adding rectangular movieclip walls to that parent.
you could then loop through all the children of that parent checking a hitTestObject between your and the child walls. if it's negative, store the ball x and y. if positive, re-assign the ball x and y to the previously stored values.
-
2. Re: How to make maze walls?
Tixzy Jun 18, 2012 5:58 PM (in response to kglad)Tried to do as you said, but as i earlier declared. I'm terrible, so the follow-up question is: What's a parent and children etc? Il understand if you wont be bothered to help me, as it may seem useless
ty for the reply thoughedit:
Would something like this be useful?if(ball.hitTestObject(wall)){
ball.y = 50
As the ball is my moving character (movieclip) and the "wall" is also a movieclip but not moving ofc?
-
3. Re: How to make maze walls?
kglad Jun 18, 2012 10:11 PM (in response to Tixzy)create your maze. convert each rectangle in the maze to a movieclip and assign an instance name (eg, m1,m2,...,m44). don't convert any L-shaped, U-shaped or rotated L-shaped, U-shaped etc sections. only rectangular blocks.
you can then use:
var prevX:int;
var prevY:int;
var i:int;
var mP:Sprite=new Sprite();
addChild(mP);
for(i=1;i<=44,i++){
mP.addChild(this["m"+i]);
}
function moveBall(evt:Event){
ball.x -= accelX*30;
ball.y += accelY*30;
if(ball.x > (480-ball.width/2)){
ball.x = 480-ball.width/2;
}
if(ball.x < (0+ball.width/2)){
ball.x = 0+ball.width/2;
}
if(ball.y > (800-ball.width/2)){
ball.y = 800-ball.width/2;
}
if(ball.y < (0+ball.width/2)){
ball.y = 0+ball.width/2;
}
checkWallF();
}
function checkWallF():void{
for(i=0;i<mP.numChildren;i++){
if(ball.hitTestObject(mP.getChildAt(i))){
ball.x=prevX;
ball.y=prevY;
break;
}
prevX=ball.x;
prevY=ball.y
}
}
}
-
4. Re: How to make maze walls?
Tixzy Jun 19, 2012 1:20 AM (in response to kglad)Im very sorry mr kglad. But it seems like I have fallen of the waggon once again.I started all over, creating the walls within an own layer and converterted each one rectangular wall to a movieclip naming them m1 to m24.
But the actionscrip seems to get bugged as i try to publish. Or i get some error messages
Don't know if you ment me to use simply the last one you posted or combine them somehow.Anyhow if I use the last one I get these errors:
Scene 1, Layer 'action', Frame 1, Line 7 1084: Syntax error: expecting semicolon before rightparen. Scene 1, Layer 'action', Frame 1, Line 8 1084: Syntax error: expecting colon before dot. Scene 1, Layer 'action', Frame 1, Line 9 1084: Syntax error: expecting identifier before rightbrace. Scene 1, Layer 'action', Frame 1, Line 11 1084: Syntax error: expecting rightparen before function. and if i try to fix them several other errors joins the party.
is it ment for me to swap something out from the code, amount of walls, wall names etc?
Again really, thanks for all the support. Wish I knew this a bit better, I am going to take some courses next year at school. Maybe i'll get it then. -
5. Re: How to make maze walls?
kglad Jun 19, 2012 6:32 AM (in response to kglad)this line:
for(i=1;i<=44,i++){
should b:
for(i=1;i<=44;i++){
-
6. Re: How to make maze walls?
Tixzy Jun 21, 2012 1:08 AM (in response to kglad)Hmm yes,
Am I wrong or is there one to many}?
Either way I'm left with tons of errors. I think I'll put this project on ice for now.
One last thing, do you know of any tutorials or online classes, preferably free?
Thanks for your attempt though.
-
-
8. Re: How to make maze walls?
Tixzy Jun 28, 2012 12:40 AM (in response to kglad)hmm alright, I must have screwed up somewhere. Anyhow il check up on it as i get home, my summerhouse dont have internett -.- bummer
thanks for your help though -
-
10. Re: How to make maze walls?
screeen Jun 30, 2012 9:09 PM (in response to kglad)Hi again, Kglad. I've downloaded this flash file with code for the maze (i too am keen to make a maze), but when i test the movie, the ball fails to move.
Am i missing something?
-
11. Re: How to make maze walls?
kglad Jun 30, 2012 9:54 PM (in response to screeen)are you testing on an iDevice?
-
12. Re: How to make maze walls?
screeen Jul 1, 2012 12:51 AM (in response to kglad)not at all, am testing on a big pc. And, BTW, when i test the Flash file, an xml file is created. Is that supposed to happen?
-
13. Re: How to make maze walls?
kglad Jul 1, 2012 5:45 AM (in response to screeen)check the publish settings. you're publishing for iOS, that's why flash is creating the xml.
also, that code uses the accelerometer to move the ball.
you need to change both to test ball movement in that file.
-
14. Re: How to make maze walls?
screeen Jul 5, 2012 2:11 AM (in response to kglad)Hi. U are right, of course. I got that code and flash file from the above link, and it is set up for mobile devices. As i understand, Accelometer is for mobile devices, and while i changed the publish settings to use Flash as the Player (instead of Air for ios which was how the file was set up), i am wondering if it is possible to use this code as such, on a big PC, not mobile device.
And, i dont know how to change the accelemeter in hte publish settings....
thank you.
-
15. Re: How to make maze walls?
kglad Jul 5, 2012 10:22 AM (in response to screeen)yes, but instead of using the accelerometer, use something else (like a keyboardevent listener) to move the ball.
-
16. Re: How to make maze walls?
Tixzy Jul 6, 2012 6:40 AM (in response to kglad)Hey i got around to test your application now. It was set on android for Ios, but i simply swapped this in settings to air for android. Since that's what im working on , but when i tested the app only one wall appear to be working, the very left one, m1. I find this rather odd since i see no difference on any of the rectangels. Did you test your app, was it fully functioning?
-
17. Re: How to make maze walls?
B_Sam Nov 28, 2012 9:46 AM (in response to kglad)Hi Kglad
I have downloaded http://www.kglad.com/Files/forums/maze.fla
I'm having the same problem as Tixy where just one wall of the left of the maze.fla file has collision, the ball MC just passes through the other walls in the project, is there something I need to change with the checkwall function?
Rgeards
Sam