A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: side following?

  1. #1
    The next Squaresoft
    Join Date
    Sep 2004
    Location
    Zanarkand
    Posts
    215

    side following?

    hmm i've been doing a platfrom game now,

    and now i've encountered a problem about
    how the enemy will face the hero

    like if the hero is on the right side of the enemy,
    it will face right

    same as the left side, if the hero at the left side
    of the enemy, then the enemy looks that way

    and i have no idea how thats done...

    anyway, thnx a bunch!
    "Are those gummy worms? Can I have some?"

    "Nevermind, I just saw one move by itself..."

  2. #2
    sophisticated
    Join Date
    Sep 2004
    Posts
    288
    gmm...
    not sure if I understood you correctly but,

    if you have a "top view", and you need to detect the position of the enemy then you can do this:

    if ( enemy._x - hero._x > 0 ) { enemy is on the right }
    if ( enemy._x - hero._x < 0 ) { enemy is on the left }
    if ( enemy._y - hero._y > 0 ) { enemy is behind }
    if ( enemy._y - hero._y < 0 ) { enemy is in front }

  3. #3
    x2i GingaNinja's Avatar
    Join Date
    Feb 2004
    Location
    England
    Posts
    217
    I am making a platformer and i used this.


    Code:
    _root.enemy.onEnterFrame = function() {
      if (_root.hero._x>_root.enemy._x) {
        _root.enemy._xscale = 100
      }
      if (_root.hero._x<_root.enemy._x) {
        _root.enemy._xscale = -100
      }
    };
    You may need to change the code a little, for example the value of 100 may distort your movie clip so you may need to experiment until you get the right size.

    Hope It Helps

  4. #4
    The next Squaresoft
    Join Date
    Sep 2004
    Location
    Zanarkand
    Posts
    215
    dude, thats exactly what i needed!

    hey thnx for the help you guys!

    OH, hey GingaNinja, I noticed you mentioned that
    you used it also in your platformer game, may
    I know its current progress?

    thnx agen!
    "Are those gummy worms? Can I have some?"

    "Nevermind, I just saw one move by itself..."

  5. #5
    x2i GingaNinja's Avatar
    Join Date
    Feb 2004
    Location
    England
    Posts
    217
    Heres a lower sized version of it as the actual file is too big.

    I haven't used that code above in this one but i have in my most recent one, it will be on my website soon - www.freewebs.com/beefcake4eva In my recent one, the terrein scrolls and it has enemys and attacks. the red one attacks using distance checks and looks quite cool when he attacks at random but kills the enemy anyway.

    It is a platformer game but it doesn't have any platforms yet, only one main one. You can jump and use the sonic style spring in th middle, the red character follows you and does kinda what you do but sometimes he does his own thing which is kinda kool, im quite impressed with it myself so far. Hope you like it.

    Controls:
    Left = Left Key
    Right = Right Key
    Jump = Up Key

  6. #6
    The next Squaresoft
    Join Date
    Sep 2004
    Location
    Zanarkand
    Posts
    215
    haha, i played wit it for 30 minutes...

    its kinda fun actually, wish yah luck on that game!
    "Are those gummy worms? Can I have some?"

    "Nevermind, I just saw one move by itself..."

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