ForumsProgramming Forum[Need help] hittest only works once?

60 13505
Voidcrystal
offline
Voidcrystal
138 posts
Nomad

when i make thise script:

onEnterFrame = function(){
if(ss.hitTest(_root.c2)){
_root.ss._x = -49.4;
}
}

it only does go to cords -49.4 once! the next time it happens nothing, can you solve it abn :P? Or anyone else??

  • 60 Replies
Voidcrystal
offline
Voidcrystal
138 posts
Nomad

how to add more classes into the same script? Like i have a turret on ss, and in the end i have to make ss._x turret._x
then i need em

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

ss.as: Line 32: The property being referenced does not have the static attribute.

that is the error when i make more classes into the script :S

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

Don't add more classes to the script. Make a brand new file for each class, or do the code inside the ss class, but use, for example, _root.ss.turret._x

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

that does not go into the script :S\\ss.as: Line 4: There is no property with the name 'speed'.
speed = 0.5

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

you need to add "var speed;" right after "class ss extends MovieClip{" Do the same for the other variables. Sorry, I forgot to tell you that.

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

Now there is another one :S

ss.as: Line 13: There is no property with the name 'muv'.
muv += speed;

plasmafish
offline
plasmafish
252 posts
Nomad

You should try using a simpler naming convention. It might make more sense then.

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

and what would that be :P?

plasmafish
offline
plasmafish
252 posts
Nomad

Try replacing muv, ss, tr , and all the oddly named variables with something more useful. You want to do this so your project doesn't get discarded in the future if you put worthwhile work into it.

I use things like countdwn, countup, charmc, enemymc, bullet, health, score, bulletspeed, charspeed, enemyspeed, lvl1score, lvl2score, enemyhealth, gravity, jump. These are all just made up names I use for different variables in games.

They all make logical sense and that is what you have to do in programming. From all of your replies I can see you are confused as to what the code is doing in each process so you can start by making your code easier to read.

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

yeah okay hehe but it still doesn't change the code, when i change it, it will still be the Error. :/

plasmafish
offline
plasmafish
252 posts
Nomad

I didn't say at all it would fix the error. They're just names, ways to visualize the way the code will act.

I am saying that maybe if you had a better understanding of how the code worked then you could possibly solve it yourself.

In flash it is all about solving the problem yourself. There is thousands of ways to accomplish each objective and you have taken the task of finding one of those ways. Since you haven't found that way yet you might want to make it easier for the people helping you.

Problems like the ones you are running into happen along every step of design in flash games. Especially if you are undereducated on the basics of flash programming. You will keep running into these "walls" (blocks of time where you cannot make progress on a .FLA because of a coding error somewhere) more and more often as the code gets longer and more variables are being passed around. This is why I am recommending that you fix all your variables to something easier for people helping you to understand. Then once the code works you can go back and change the variables/instance names to whatever you want.

If what I said didn't make much sense then my only recommendation is to read a couple books on flash and then try making a game again.

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

Yeah i know that the names would fix it, i also know i need to find them out by myself. I am trying to fix the problems in about a day before i post them here so i am really trying but this problem is nothing i understand because i don't know how to make a class "class script is new for me".

Do not think that i am a lazy slacker that wants help everytime i run into a problem, i do not know how to fix this problem in any way! So what should i do if i don't get any help ?

any book suggestions?

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

I actually found a way to solve this problem in my head when i was in my car (without the class script) but what i ment before that i couldn't solve the class script, not the problem itself .

Btw thanks for the advice of making it variables that i can remember, i did not think of that it would be harder when it got more and more variables.

alsage
offline
alsage
132 posts
Nomad

try this

this.onEnterFrame = function()
{

if(_root.ss.hitTest(_root.c2))
{
_root.ss._x = 49.4;
}

if there are any problems you are haveing with code contact me on my profile
}

plasmafish
offline
plasmafish
252 posts
Nomad

Awesome that you figured it out in your head. I also solve my hardest flash problems when I am not sitting at the computer.

If you are programming in AS2.0, I would recommend Flash MX/8 books. Books such as Flash MX Advanced, and maybe Macromedia Flash Professional 8 Game Development.

Showing 46-60 of 60