00:00
00:00
Newgrounds Background Image Theme

Chan99 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Hittest Problem

581 Views | 14 Replies
New Topic Respond to this Topic

Hittest Problem 2006-08-03 03:38:53


I want my character to shrink the further into the background he comes and I want to use hittest to make him do it.. the problem is that flash will only accept one hittest object that will change his size, if I have more it will only use the first and ignore the rest even if it isnt the same object...got any ideas or an alternative way to fix the problem please post it here.

Response to Hittest Problem 2006-08-03 03:41:24


Why not just use _xscale / _yscale? There's really no need to use hittests in this type of scenario.


Non-dairy produkt

BBS Signature

Response to Hittest Problem 2006-08-03 03:51:18


At 8/3/06 03:41 AM, TremcladClock wrote: Why not just use _xscale / _yscale? There's really no need to use hittests in this type of scenario.

would you like to show me..I dont know how to use that script..

Response to Hittest Problem 2006-08-03 03:57:15


Posting some scripts could help but I'm guessing you may be advantaged by using else statements


.

BBS Signature

Response to Hittest Problem 2006-08-03 03:59:33


Damn im stupid..Ive shouldve just used the search bar..find alot of code that I can use there..sorry for posting such an useless thread...sorry guys

Response to Hittest Problem 2006-08-03 04:05:02


This code will do exactly what you want, "speed" is a variable declared in the "load" section.
if(Key.isDown(38))
{
this._y = this._y - speed;
this._yscale--
this._xscale--
}
if(Key.isDown(40))
{
this._y = this._y + speed;
this._yscale++
this._xscale++
}


Non-dairy produkt

BBS Signature

Response to Hittest Problem 2006-08-03 04:25:08


Is it possible to have those effects while using the script below? and if were should I add it...I didnt quite understand when you mean speed variable in load section..if you got the time please correct me. ignore the gotoAndPlay()s cause their just for the leg animation.

onClipEvent (enterFrame) {
if (Key.isDown(37)) {

_x=_x-2;
this.gotoAndPlay(3);
}

if (Key.isDown(38)) {
_y=_y-2;
this.gotoAndPlay(1);

}
if (Key.isDown(39)) {

this.gotoAndPlay(4);

}
if (Key.isDown(40)) {

}
if (hitTest(this._parent.shrink2)==true) {
this._width= 45;
this._height=75;

}
if (hitTest(this._parent.shrink2)==false) {
this._width= 50;
this._height= 80;
}
if (hitTest(this._parent.legg)==true) {
this._width= 40;
this._height= 70;
}
}

Response to Hittest Problem 2006-08-03 04:27:39


shit..I missed some but you understand that its supposed to be_y=_y+2and _x=_x+2;
on the ones that were empty right?

Response to Hittest Problem 2006-08-03 04:36:19


on the subject of hittest problems.

check this out and see if you can come to a logical conclusion as to why it's fucked up.

http://img153.images..?image=savengwx3.swf

Response to Hittest Problem 2006-08-03 04:58:07


At 8/3/06 04:05 AM, TremcladClock wrote: This code will do exactly what you want, "speed" is a variable declared in the "load" section.

I Figured out what you mean with speed is a variable declared in the "load" section..but
it just boost the speed of the movement..the size of the clip wont change at all...

Response to Hittest Problem 2006-08-03 05:11:44


At 8/3/06 04:36 AM, Dogget wrote: on the subject of hittest problems.

check this out and see if you can come to a logical conclusion as to why it's fucked up.

http://img153.images..?image=savengwx3.swf

Keep your questions in your topic go there I have answered your question and to topic starter:
Instead of using _x = _x-2 just write _x-=2 it's quicker and easier and less memory consuming( although only on a very small scale), however that has nothing to do with your problem;)


.

BBS Signature

Response to Hittest Problem 2006-08-03 05:22:27


Instead of using _x = _x-2 just write _x-=2 it's quicker and easier and less memory consuming( although only on a very small scale), however that has nothing to do with your problem;)

Hey Im glad that somebody actually stopped to help me in the first place =)

I came to the conclusion that I wont use the scaling things and instead only have very small areas to take you places like in Resident Evil...then I need no scaling

Response to Hittest Problem 2006-08-05 08:55:31


I guess its better to keep posting in this thread instead of making a new one..but seriously Ive tried to find a solution to this problem...

Look at this script:

onClipEvent (enterFrame) {
if (Key.isDown(37)) {
_x=_x-1;
this.gotoAndPlay(8);
}

if (Key.isDown(38)) {
_y=_y-1;
this.gotoAndPlay(1);
}
if (Key.isDown(39)) {
_x=_x+1;
this.gotoAndPlay(12);

}
if (Key.isDown(40)) {
_y=_y+1;
this.gotoAndPlay(4);

}
}
Ive got four different walking animations.. up,down,right, and left.

The problem is if I press two buttons at once...like down and right..the walking animation freezes...so basicly I am wondering if there is a nice way to enhance this script so that I can have two buttons pressed at once and still have the person walk sideways without the freezing part...if you didnt understand just ask and I will try to make it clearer...any help at all appreciated cause I just couldnt find this part in the tutorials.

Response to Hittest Problem 2006-08-05 11:55:53


Yea, but not with how the fla of the characters are set up. I use a simple solution to this problem.

Response to Hittest Problem 2006-08-05 15:21:04


ok, last try...so nobody knows a way too fix this? I wont post here anymore if nobody answers...just wanna know this because it looks like shit if it cant be fixed.