Actionscript fun….

Posted on September 2, 2012

2


… I’m feeling like a “real” … oh, programmer wouldn’t be the right term, but I just took a teeny bit of code through a fine tooth comb and … decided to try Different Things than the words… I’m trying to make a pingpong game per lynda.com and I set the “ball” to move as it entered the frame (as in move all the time) — and then, if it got to the bottom or top of the stage, to change direction.  So the code was simple — if the x was less than zero or more than the edge (minus its width), it should change direction – multiply the distance added with each frame by negative one.   Same stuff for width.

So I get her rolling and she bounces to the top of the stage, then keeps slamming into the top of the stage as it goes the rest of the way to the upper right corner, and just shoves its little nose against the corner, again and again and again, as if it were changing direction every frame. So the “minus one” thing was working — but working too well.  Should the code have included something to turn it off?  I really really REALLY compared all the code… made sure I hadn’t capitalized something, etc… no joy… I have gotten reasonably good at that… and after half an hour decided to Try Totally Unrelated Things.

Seems just moving the starting point of the ball changed everything.   I started it at 0,0  and … it went up and down the left side.   So from there, only the “x” direction stuff was ftummeled. Anotehr spot sent it to the lower right corner… and… at the point where it was in the original tutorial, it worked just fine.  I have to wonder, though, whether there are “sensitive spots” on the stage that it would hit and get sent into “beat your head against the wall” mode. I sent an email to tech support, since I got a reasonably quick response from the author last time I did that (there was some of the code that didn’t apply to this version of Flash) and oh, my! my question got put in the FAQ 🙂   (Yes, more “feel like a real nerd” points ;))

Alas, this is not even as far as I got with this the last time I tried (and I got a little further and something made me stop)… and I *did* just stop playing with the “monster” game (that had the ‘some of it doesn’t apply to CS6″ stuff) because I just couldn’t find where I’d gone wrong (and I really want to get to “keeping score!”)

 

Advertisements
Posted in: flash animation