Be a Supporter!

hitTest help

  • 350 Views
  • 13 Replies
New Topic Respond to this Topic
TheMasterOfSprites
TheMasterOfSprites
  • Member since: Dec. 14, 2002
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
hitTest help 2009-03-22 21:57:55 Reply

Hey, I am having an issue with my RPG. I didn't want to post asking for help again but I am lost. I keep trying to program a hitTest. The idea is that when an invisible square box hits my character it will move to the next scene, which is were I programmed my "Random Battle." So I have the random battle all set up and I have the box seeable right now for testing. The big problem is every time it hits the movie clip, which is inside another movie clip; it doesn't seem to do anything. Here is my coding on the player.
onClipEvent(enterFrame){
if(this.hitTest(_root.area.bot)){
nextScene();
}
}
Now, maybe you can't use a next scene action on a player, (player being the character that is hitting the box,) but if that is the case how do I go about solving my problem? I tried modifying the code and placing it in several places. Is there something fundamentally wrong with it?

Johnny
Johnny
  • Member since: Apr. 17, 2004
  • Offline.
Forum Stats
Member
Level 24
Blank Slate
Response to hitTest help 2009-03-22 22:11:13 Reply

Try:

_root.nextScene();


Perpetually looking for time to return to the arts.

BBS Signature
TheMasterOfSprites
TheMasterOfSprites
  • Member since: Dec. 14, 2002
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to hitTest help 2009-03-22 22:16:56 Reply

Still have the same problem.

TheMasterOfSprites
TheMasterOfSprites
  • Member since: Dec. 14, 2002
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to hitTest help 2009-03-23 00:47:56 Reply

I'm sorry, I am still having issues.

TheSongSalad
TheSongSalad
  • Member since: Jan. 17, 2009
  • Offline.
Forum Stats
Member
Level 19
Audiophile
Response to hitTest help 2009-03-23 00:58:41 Reply

perhaps _root.gotoAndStop(#); instead of nextscene();? the '#' would be the frame of your random battle.

BillysProgrammer
BillysProgrammer
  • Member since: Sep. 17, 2008
  • Offline.
Forum Stats
Member
Level 16
Gamer
Response to hitTest help 2009-03-23 01:03:05 Reply

There is no nextScene() command I believe.

_root.gotoAndStop("SCENE_NAME", FRAME# to start, default 1);
TheMasterOfSprites
TheMasterOfSprites
  • Member since: Dec. 14, 2002
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to hitTest help 2009-03-23 01:05:36 Reply

At 3/23/09 01:03 AM, BillysProgrammer wrote: There is no nextScene() command I believe.

_root.gotoAndStop("SCENE_NAME", FRAME# to start, default 1);

Didn't work.

BillysProgrammer
BillysProgrammer
  • Member since: Sep. 17, 2008
  • Offline.
Forum Stats
Member
Level 16
Gamer
Response to hitTest help 2009-03-23 01:10:05 Reply

Then you have done something wrong, I know for a fact it worked on mine. I always test before I post.

TheMasterOfSprites
TheMasterOfSprites
  • Member since: Dec. 14, 2002
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to hitTest help 2009-03-23 01:14:37 Reply

At 3/23/09 12:58 AM, TheSongSalad wrote: perhaps _root.gotoAndStop(#); instead of nextscene();? the '#' would be the frame of your random battle.

That works, thank you, but I wish I could use scenes to organize.

TheSongSalad
TheSongSalad
  • Member since: Jan. 17, 2009
  • Offline.
Forum Stats
Member
Level 19
Audiophile
Response to hitTest help 2009-03-23 01:50:20 Reply

you can. do you know how to name them?

TheMasterOfSprites
TheMasterOfSprites
  • Member since: Dec. 14, 2002
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to hitTest help 2009-03-23 02:01:13 Reply

At 3/23/09 01:50 AM, TheSongSalad wrote: you can. do you know how to name them?

I tried naming it, but it still didn't work.

TheSongSalad
TheSongSalad
  • Member since: Jan. 17, 2009
  • Offline.
Forum Stats
Member
Level 19
Audiophile
Response to hitTest help 2009-03-23 03:28:51 Reply

i guess ask someone else, i just use frame numbers, sorry man.

Kwing
Kwing
  • Member since: Jul. 24, 2007
  • Offline.
Forum Stats
Member
Level 45
Game Developer
Response to hitTest help 2009-03-23 10:48:08 Reply

Sorry, I can't quite say I know what you're asking. Perhaps a basic rundown of where the script is/what MC's you have, etc.


If I offer to help you in a post, PM me to get it. I often forget to revisit threads.
Want 180+ free PSP games? Try these links! - Flash - Homebrew (OFW)

Denvish
Denvish
  • Member since: Apr. 25, 2003
  • Offline.
Forum Stats
Member
Level 46
Blank Slate
Response to hitTest help 2009-03-23 10:53:58 Reply

Also not exactly clear on your problem, but try this

Add this function on the main timeline

function NS(){nextScene();}

With your code, first run a trace to check your hitTest is working

onClipEvent(enterFrame){
	if(this.hitTest(_root.area.bot)){
		trace("HIT");
		nextScene();
	}
}

If that outputs HIT when tested, remove the trace and replace the line nextScene(); with _root.NS();


- - Flash - Music - Images - -

BBS Signature