Welcome!!!

Take a look and be amazed!

Wednesday, April 14, 2010

Current programming issues HELP!

So far ive got the programming for up and down, but i cannot get the left and right to work. ive tried making my own code and copying other codes and left and right still dont work. they work in the original code i copied them from, but cease to work on mine. if anyone can take a look at my coding and tell me why the left and right codes arent working, please help!!! up and down work fine.

ball._x = 400;
ball._x = 1;
onEnterFrame = function() {
ball._x = ball._x + 4;

if (Key.isDown(Key.UP)) {
ball._y -=10;
}
if (Key.isDown(Key.DOWN)) {
ball._y +=10;
}
if (Key.isDown(Key.RIGHT)) {
ball._x +=10;
}
if (Key.isDown(Key.LEFT)) {
ball._x -=10;
}
ball._x = 5;
}

4 comments:

  1. Hello, I believe your issue is that on your next to last line, you are constantly resetting your x coordinate back to 5. Delete this line "ball._x =5;" and you should be able to move horizontally. You probably are moving the ball left or right, but as soon as it happens, that line of code brings the ball right back to x=5. Hope that helps, Patrick Smith (smith288 on MCTCWiki)

    ReplyDelete
  2. hey,

    Still having issues with that script ?

    ReplyDelete
  3. Andrew, looking at what you had accomplished in class on the 16th, I'd say you solved your problem. Nice discovery about the walls and keeping the ball inside!

    ReplyDelete
  4. Yes!!! i got it! A little bit of trial and error and some help from everyone! there is still a little i need to learn about walls and boundries.

    ReplyDelete