i have some white circle movie clips (instance name limit) in a movie clip called map.
when it hits the limit movie clip i want it to stop, the problem with taht is it scrolls into the circle a bit before stoping (the player and the object partly overlap) and its easy to get stuck.
I want it to stop as soon as one edge ofd the player hits one edge of a wall.
tahts the first thing
the 2nd thing is that i have 7 or something of them circle movie clips in the map movie clip (all instanced named limit), and it only works for one. I need it so i can make many diffrent walls and boundaries of diffrent shapes and locations.
help is apreciated! ive been looking for days.
You don't need to post this twice. I just answered your question here .
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD WEI Score: 7.6
i now have another issue (i know that codes not very good above, because i just tryed to make it work) and i was wondreing if that was somewhat close to what i should be doing to make mutiple walls.
Hey, i'm a bit of a newbie with flash and programming in general, but I'm attempting to make a 2 player game where u run around and shoot the other player. I'm fine with the moving, (p1=arrowkeys p2=wasd) and p1 can shoot, however I'm having some trouble with testing whether p2 collides with the bullet. The code I am using for the bullet is:
Code:
var bulletSpeed=8;
var bulletReady=true;
var bulletDelay=55;
var bulletArray=[];
var bulletCount=0;
function createBullets(){
var bulletMc=this.attachMovie("bullet", "bullet"+bulletCount, 1000+bulletCount);
bulletCount++;
bulletMc._x+=dude._x-10;
bulletMc._y+=dude._y+15;
bulletArray.push(bulletMc);
}
function moveBullets(){
if(bulletReady&&Key.isDown(Key.SPACE)){
bulletReady=false;
currentTime=getTimer();
createBullets();
}else{
if(currentTime+bulletDelay<=getTimer()){
bulletReady=true;
}
}
for(var i=0; i<bulletArray.length; i++){
bulletArray[i]._x+=bulletSpeed;
}
}
this.onEnterFrame=function(){
moveBullets();
}
and p2 is called dude2. wondering if somebody could give some suggestions as to what code I would insert if I wanted p2 to lose 1 life per time he was hit with a bullet, with a max of 5 lives, and then game over.(note: p2 can't shoot yet, but I'm working on that later)
you can do multiple things, what I would do, which may not be correct, is:
Inside the original "bullet" movie clip, right click, and hit actions, and then add this code
onClipEvent(enterFrame){
if(this.hitTest(dude2)){
dude2health --
}}
that says that every frame every bullet exists in, it will check if it is touching "dude2". and also, if it does, dude2health will decrease by one.
HitTest is a very useful, and can be used for just about anything (like ductape really). There are two main forms that it takes:
Code:
if(this.hitTest(another_clip)){
// Something
}
This just tests the bounding boxes of this, and another_clip. If they hit, then the contents of the if will run.
Code:
if(this.hitTest(x, y, true)){
// Something
}
This tests the point x,y against the contents of this, the actual shape and not the bounding box. The true is what makes it test against the shape and not the bounding box.
Anyone else want to continue?
(if it's an irrelevant post, it'll be edited out as this is a guide sticky, not just a general bantering one )
i dont understand how i am suppposed to properly use these, your explanation confused me. is there an example you can use?
hello again old friend. I will give you instructions:
Make a square movie clip with an instance name of hero.
make another square movie clip with an instance name of enemy.
thats it. now to the code:
if(hero.hitTest(enemy)){ //read this as IF HERO HITS ENEMY, THEN
trace("you hit the wall you dope")
}
that should work, of course you have to allow the hero to move so you can test whether he hits the wall or not. Or you can place the hero on top of the wall and it will trace that line. Sorry i didnt put it in a code /code thing i was lazy.
If the only tool you have is a hammer, you tend to see every problem as a nail.
did you try changing THIS to your INSTANCE NAME? and _x and _y to the actual numbers?
This code is attached to one on my odd shaped Instances that is why I used the THIS.
How would changing the _x and _y work? This would set a specific collision detection sport and not the edge of the odd shape.
Have a quick look at the fla I have atached to my original message.
I want my two Instances of odd shapes to colllision detect when the actual shape pixels come into contact and not when they're boundry boxes come into contact.
go to kirupa.com and look for the hittest they have. They made it odd shaped just for you. I didn't look at the fla again hehe. but this is not for odd shaped stuff.
If the only tool you have is a hammer, you tend to see every problem as a nail.
My own solution that I have found that works.
What I have ended up doing is placing lots of little duplicated hitTest instaces which are just circles around the outer edge of my complex odd shape.
Only when one of these little cirles is hit the do something takes place.
I did find a nice webpage tutorial explaining about technique this but I have lost it and can't find it agian. If you would like me to throw together an example fla file then just ask me and I will.