Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Flash Problems

Options
  • 07-04-2010 5:10am
    #1
    Closed Accounts Posts: 2


    Hi folks, have 2 probs, prob stupid but if anybody can help i would be grateful:)

    First prob is the top edge of my stage(600, 420), i want to limit my sprites to the stage and create a barrier to stop them moving off it. the following works for left right and bottom but not for the top
    ---
    if (playerRobot._x>Stage.width) {
    playerRobot._x = (Stage.width-1);
    }
    if (playerRobot._x<0) {
    playerRobot._x = 1;
    }
    if (playerRobot._y>Stage.height) {
    playerRobot._y = (Stage.height-1);
    }
    //problem
    if (playerRobot._y<0) {
    playerRobot._y = (Stage.height-40);
    }

    ---
    Any ideas?



    Secondly, i am creating multple instances of a cpuMissile and want to paas its attributes to the turn() function which moves the missile.The problem only occurs when i try to use multiple instances????


    function cpuMissileLaunch()
    {
    sndMissileLaunch.start();
    i++;
    _root.attachMovie("cpuMissile", "cpuMissile" + i, _root.getNextHighestDepth());
    _root["cpuMissile" + i]._x = cpuRobot._x;
    _root["cpuMissile" + i]._y = cpuRobot._y;
    //cpuMissile._X = cpuGun._x;
    //cpuMissile._Y = cpuGun._y;
    _root["cpuMissile" + i].dir = cpuGun.dir;
    _root["cpuMissile" + i].speed = (((cpuRobot.weapon*5)));
    turn(_root["cpuMissile" + i]);
    }

    .speed and .dir are already declared in an init function
    thoughts?


Comments

  • Closed Accounts Posts: 7,145 ✭✭✭DonkeyStyle \o/


    //problem
    if (playerRobot._y<0) {
    playerRobot._y = (Stage.height-40);
    }

    ---
    Any ideas?
    zero is the top of the Y axis, stage.height-40 would be 40 pixels from the bottom... you could just set this to zero or some other fixed offset depending on the size of the sprite and where the anchor point is.
    if (playerRobot._y<10) { playerRobot._y = 10; }

    Haven't really been able to digest the rest... though you might have better luck using 'this.' instead of '_root["cpuMissile" + i]' as it'll refer to that instance (I presume these are member functions) and with each new instance 'i' might be resetting to default, so it's just passing the same missile over and over?
    Add in some trace() statements, see what the turn function is receiving.
    Sorry my AS3 is still a bit basic.


Advertisement