Sign in to follow this  
TheFlea

Collision , then Stop

Recommended Posts

Ok, i'm tring to learn flash (action script) . I have a mc whice go to mouse when i press leftbutton.This is the code:
onClipEvent(load){
    _x=0;
    _y=0;
    slow=10;
}
onClipEvent(mouseDown){
    endX=_root._xmouse;
    endY=_root._ymouse;
}
onClipEvent(enterFrame){
    _x +=(endX- _x)/slow;
    _y +=(endY- _y)/slow;
}
and code for hitTest(collision) is
_root.mc.hitTest(_root.mc2)
My question is .. what i need to do for stop my increment and stop my mc nearly mc1 when my first touch other mc, say mc1 . Thank's in advice.

Share this post


Link to post
Share on other sites
I don't personally know Flash, so I cannot help within the Flash context; only for game design in general.

I suspect no one is replying because the code you posted...as well as your question wording... seem to indicate an extreme lack of conceptual knowledge. And people do not like to deal with that in general. Since that level of conceptual difficulty is pretty hard to assist without being in person with a whiteboard available.


Please try to give a carefully worded description of your programming experience. We could give you suggestions... but we aren't sure if they'd just fly over your head or not at this point.



My first recommendation is:
You need to rethink your game architecture. The code you posted earlier seems to be a series of Event handlers. A game generally has a Main Loop that drives everything; this would be the location where you'd detect a collision and respond... Events being limited to user input generally...


So, if Flash is actually your first programming experience, and you have no idea about a Main Loop, and are stuck in the Event and message based paradigm... we have some work to do...
I hope this is not the case... because thats most likely the reason no one's commenting; it would be painful to try and deal with...

Share this post


Link to post
Share on other sites
Well, anytime you want something to stop, you add logical code to perform a check of when to stop that handles what to do next when something takes place, a trigger point of some sort in code that skips the uneeded/unused portions. Programatically in Flash you can have simple logic to skip sections of code and/or frames or events when something occurs. Flash programming can be a bit tricky to work with due to limitations of language interpretation and flexibility of scripting to work with objects and things which the Flash Development Environment offers.

Function or Sub Routine Entry Point:
If intCount = 3 Then Goto CheckSkippedBecauseCountEqualledAValueWeDeemedAStoppingPoint

'Perform Check. (Check Ignored when intCount = 3)
CheckForSomething

CheckSkippedBecauseCountEqualledAValueWeDeemedAStoppingPoint:

Share this post


Link to post
Share on other sites
Quote:
Original post by TheFlea
what i need to do to ... stop my mc nearly mc1 when my first touch other mc, say mc1 .

Thank's in advice.


Do you realize how many grammatical errors there are in this sentence. The sentence is all to waste, as there is no mention of an mc1 variable in any of your code.

what do these mean?
"Thank's in advice"
"stop my mc nearly mc1"
"when my first touch other mc"

If English is your second language then I maybe you should try parsing a sentence in your own language trough a translator. Maybe you will have better luck.

Share this post


Link to post
Share on other sites
Quote:
Original post by jlewicki
Quote:
Original post by TheFlea
what i need to do to ... stop my mc nearly mc1 when my first touch other mc, say mc1 .

Thank's in advice.


Do you realize how many grammatical errors there are in this sentence. The sentence is all to waste, as there is no mention of an mc1 variable in any of your code.

What purpose does this serve, other than to feel good about being better at your language than the OP?

If you wanted to say something useful, you could just say what you don't understand, and what he'll have to explain about his code.
It seems to me the problems aren't with his english as such, just that he didn't explain his problem and his code properly.

Quote:

If English is your second language then I maybe you should try parsing a sentence in your own language trough a translator. Maybe you will have better luck.

Since english isn't your second language, then maybe you should try 1) having to communicate in another language, and 2) Try actually *using* an online translator before suggesting it. That's quite possible the worst thing he can do.

Share this post


Link to post
Share on other sites
Don't learn how to program with flash. In my experience with flash, as I use it quite often, you will get a misconstrued idea of how actual games are made. For instance, you said you're using MC, which is a "bad" way to set up a game. Also you said you want to use _root.mc.hitTest(_root.mc2). The hitTest function in the movie clip was never designed to be used for a game. For one it is a very CPU intense function and it's also very hard to use with impulse forces for pushing two objects apart after a collision (that's saying the object didn't go right through the other object).

I recommend using a language with no GUI or drawing, as these will confuse you as to how game programming normally is. Try C++ or some other language.

As for movie clips, the bitmap rendering is much faster and is used more often now.

Not to discourage you though, I just don't want you to "waste" time with non-conceptual programming paradigms.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this