Skip navigation
Currently Being Moderated

hitTestObject HEADACHE!

Apr 10, 2012 1:49 PM

I have a vision of a game I would love to create but I'm new to Actionscript 3, and I have been working my way through an online tutorial, trying to use the code given and adapt it to a game I am working on, which kind of has similarities, but now I'm completely stuck. (I've probably bitten off more than I can chew, but I don't want to give up on my game idea)

 

The online tutorial is for creating a vertically scrolling shooting game where you control a Space ship and you shoot at enemy ships which fall vertically downwards randomly.

The hitTestObject on the online game is between bullets shot from your ship and the enemy ship itself.

 

My game is a horizontal scrolling scene where the user controls a flying superhero, which starts at the left, and items move across the screen from right to left towards the superhero and you have to collect ("hit") certain items. My hit test is to be between the superhero himself and these moving items. He doesn't fire anything.

 

Here's a screenshot of MY game (not the online tutorial game):

game.jpg

 

 

 

 

This is the section of the tutorial that I am stuck on, as my game does not involve anything "shooting" anything, rather just a character that hits objects, no weapons. And the online tutorial uses the weapon's bullets for doing the hitTestObject, so I don't know how to use the code on my superhero as opposed to "bullets".

 

http://asgamer.com/2009/as3-flash-games-for-beginners-registering-hit- tests

 

 

I think the tutorial is excellently explained, but as I'm trying to adapt it to a different game it's very complicated and confusing for me, and being a beginner at Actionscript3 doesn't help.

 

If anyone can tell me what I can show here or explain better here to receive help then please let me know, because I'm determined to do it.

 

ALL and ANY help and advice is extremely welcomed!!!

Many many thanks in advance.

 
Replies
  • Currently Being Moderated
    Apr 10, 2012 2:12 PM   in reply to le_mac_man

    The thing you could show would be the code that is giving you a headache.  In general, if there is only one hero and many objects to hit him, have each of the objects do its own hitTestObject against the hero as they move.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 11, 2012 12:19 PM   in reply to le_mac_man

    As I said, you can do the hitTest in the Carrot objects as they move.  You move them in the loop function, so in that function is where you should do the hitTest.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 11, 2012 5:55 PM   in reply to le_mac_man

    You're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points