A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] trying to figure out this "if"

  1. #1
    Junior Member
    Join Date
    Jul 2015
    Posts
    8

    resolved [RESOLVED] trying to figure out this "if"

    im trying to figure out why this declaration will not work

    it is suppose to move the enemy when its 100px near the player
    and stop when its 10 px away from player

    please let me know if you know why it does not work


    if(xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
    and xclose>=10 and xclose<=-10 and yclose>=10 and yclose<=-10)

  2. #2
    Junior Member
    Join Date
    Jul 2015
    Posts
    8
    ive figured out if anyone is intersted

    if(xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
    and xclose>=20 or
    xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
    and xclose<=-20)

  3. #3
    Junior Member
    Join Date
    Jul 2015
    Posts
    8
    this is the final code if you know a simpler way please let me know

    if(xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
    and xclose>=20 or
    xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
    and xclose<=-20 or
    xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
    and yclose>=20 or
    xclose<=100 and xclose>=-100 and yclose<=100 and yclose>=-100
    and yclose<=-20)

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Why not just use two simple if's like so.
    PHP Code:
    if (xclose <= 100 && xclose >= -100)
    {
        
    trace("xclose");
    }
    if (
    yclose <= 100 && yclose >= -100)
    {
        
    trace("yclose");

    You don't need the xclose 20 or -20 as it counteracts the 100 -100

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