The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.39 / 5.00 38,635 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 15,161 ViewsHi,
I am making a game don't really need to go into much detail about the game but im trying to make a wall that if the player (its a square)
is bigger than i certain height wont be able to go thought then when it becomes bellow the height it can go thought it.
so here is the AS2
onClipEvent (enterFrame) {
if (this.hitTest(_root.player1 && _root.player1._height>13)) {
_root.player1._x -= _root.player1.Pspeed;
} else {
}
}
so its the normal hitTest thing and it works fine if you remove the "&& _root.player1._height>13" but im not sure if thats how you are ment to write it out for the height.
Thanks
Eli
| How long is a peace of string?
At 5/28/09 12:59 PM, captinx wrote: Hi,
I am making a game don't really need to go into much detail about the game but im trying to make a wall that if the player (its a square)
is bigger than i certain height wont be able to go thought then when it becomes bellow the height it can go thought it.
so here is the AS2
onClipEvent (enterFrame) {
if (this.hitTest(_root.player1 && _root.player1._height>13)) {
_root.player1._x -= _root.player1.Pspeed;
} else {
}
}
so its the normal hitTest thing and it works fine if you remove the "&& _root.player1._height>13" but im not sure if thats how you are ment to write it out for the height.
Thanks
Eli
Try:
onClipEvent (enterFrame) {
if (this.hitTest(_root.player1) && _root.player1._height>13)) {
_root.player1._x -= _root.player1.Pspeed;
} else {
//nothing, that makes it just go through.
}
} At 5/28/09 12:59 PM, captinx wrote: onClipEvent (enterFrame) {
if (this.hitTest(_root.player1 && _root.player1._height>13)) {
_root.player1._x -= _root.player1.Pspeed;
} else {
}
}
try:
onClipEvent (enterFrame) {
if (this.hitTest(_root.player1) && _root.player1._height>13) {
_root.player1._x -= _root.player1.Pspeed;
}
}
you need to split up the hitTest and the inequality
At 5/28/09 12:59 PM, captinx wrote: onClipEvent (enterFrame) {
if (this.hitTest(_root.player1 && _root.player1._height>13)) {
_root.player1._x -= _root.player1.Pspeed;
} else {
}
}
Almost - you need to close the parentheses for your hitTest -
if (hitTest(_root.player1) && _root.player1._height>13) {
You've got two different conditions - the hitTest and the check on your height. The comparison needs to be between the two conditions - you had it inside one. I'm explaining this badly :/
Also, I'd reccomend using a while loop to move your player back, since it allows for both smoother pushing back and generalisation to irregular surfaces:
if (hitTest(_root.player1._x - 10, _root.player1._y, true) && _root.player1._height>13) {
do{
_root.player1.x ++;
} while(hitTest(_root.player1._x - 10, _root.player1._y, true));
};
I'd also reccomend against using the _height property to determine things since it's vulnerable to bugs and scaling e.t.c. You can give your guy a property or something to determine if he's big or not:
guy.isSmall = false;
if(... && guy.isSmall)
if (this.hitTest(_root.player1 && _root.player1._height>13)) {
if(this.hitTest(_root.player1) && _root.player1._height > 13) {
Thanks guys for your fast replys.
They all worked fine :)
| How long is a peace of string?