A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Collision Test in RPG Game: ADVANCED PROBLEM

  1. #1
    Junior Member
    Join Date
    Oct 2000
    Posts
    27

    Collision Test: ADVANCED PROBLEM --> Part II

    Hey,

    first of all: I have read all the sites which were suggested by EdMack. One of those sites (http://www.freewebz.com/savco/tutorials/collision.htm) dealt very comprehensive with the collision detection.

    I have created a game where a figure will be moved through the room and before each move takes place a hitTest function checks, if next step would collide with the outer boundaries which limit the room so that the figure is not falling off the stage or walking through objects...of course.

    There are 4 MCs (figure walking up, down, right, left) lying above each other and one normally invisible MC called base which will be compared in the hitTest function with the boundaries.

    I cannot explain all the code, thats why I have uploaded the *.fla and the *.swf so you can check everything out.

    THE PROBLEM: it just doesn't work!!!!!!! It sometimes works and sometimes not...

    This is so important because until now, nobody deals with games which are not tile based and depends on collision testing.

    The FLA: collide.fla
    The SWF: collide.swf

    When somebody please can help me then I will post a tutorial on flashkit!!!!!!!!!

    THANK YOU SO MUCH if even one could give me a hint!
    Last edited by Zacky2001; 10-14-2002 at 03:09 PM.

  2. #2
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    test my open source fla here:

    http://www.marmotte.levillage.org/fi...cky_pack02.zip

    ^ this is an open source of my little web site (the link in my signature), if you want to see how the hitTest is working here (btw i'm using Ed's code for that)

    hope it helps

  3. #3
    Junior Member
    Join Date
    Oct 2000
    Posts
    27

    thanks

    Sali marmotte,

    this is just what I looked for!! Will go through it as soon as I am home from work and give you a note if it worked for me :-) But again thanks!
    BTW: AWESOME GRAPHICS!!!!!!!!!

  4. #4
    Junior Member
    Join Date
    Oct 2000
    Posts
    27

    Thanks marmotte, but... (swapDepths)

    Hey Marmotte,

    thanks (also to EdMack)! Works GREAT!!! But how would you do a swaptDepths operation when the character walks accross the room and the furniture should swap their depths with the character depending if it is standing in front or behind?

    I have tried it with the HitTest function again but then its constantly swapping depths but I only want to swap once.

    If you or anybody knows where to get this info, I'd be grateful!

    Thanks to you!
    Zack

  5. #5
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    did you tried the "classic" swap code:
    _root.character.swapDepths(_root.character._y*240+ _root.character._x);


    if you don't see what i'm talking about, i'll be more specific...

  6. #6
    Junior Member
    Join Date
    Oct 2000
    Posts
    27

    swap.Depths

    Hey marmotte,

    I have tried it like this:

    if (_root.hittestarea.HitTest(_root.character) {
    _root.furniture.swapDepths(_root.character);
    }

    but everytime when the character walks in, HitTest returns constantly true what means, I've got a constant swapping of depths between the two MC's furniture and character.

    What I did now is: created two layers, one above and one beyond the character with booth the exact same content and set the visibility of the above layer on false. When the character now walks behind the furniture (on the hittestarea), the beyond-layer will be set to ._visible = false and the above-layer to ._visible=true.

    It's not perfect, though, but it works. Got any better idea respt. might you be more specific on your code?

  7. #7
    Senior Member g_M_e's Avatar
    Join Date
    Jun 2002
    Posts
    147
    Marmotte! I came across your site the other day. Very nice. Now I've found your post on collision detection. You give a link for your open source pack, but I get a 404 when I try to download it. Could you PLEASE PLEASE make it available again. Thanks in Advance!
    g_M_e

  8. #8
    Gross Pecululatarian Ed Mack's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    2,954
    Here's what you want I think.
    Attached Files Attached Files

  9. #9
    And loving it!
    Join Date
    Mar 2001
    Posts
    26

    marmotte's source code

    yes would love to look at your source code marmotte - but your link doesn't work.

    thanks

  10. #10
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    sooooooo, here's something very interesting for you:
    http://www.marmotte.levillage.org/files.html

    enjoy ^^

    see you later
    Last edited by marmotte; 12-17-2002 at 07:36 AM.

  11. #11
    And loving it!
    Join Date
    Mar 2001
    Posts
    26
    much appreciated

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center