Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-31-2012, 10:51 PM   #1
Registered User
Join Date: Jun 2012
Posts: 8
Default How to Make MovieClip Appear Randomly Within a Certain Area?

I am making a baseball game and I'm having trouble with making the ball go to a random x and y position. I can make the ball be hit, but I want it to be random power. Like sometimes it goes far and sometimes it stays in the infield. But right now it only goes far. Here's the code:

ActionScript Code:
onClipEvent (load) {     i = 15;     k = -Math.PI+Math.random()*Math.PI;     this._xscale = this._yscale=50+Math.random()*100;     this._alpha = 75+Math.random()*100;     } onClipEvent (enterFrame) {         rad += (k/180)*Math.PI;     this._x -= Math.cos(rad);     this._y -= i;     if ((this._x>=movieWidth) || (this._x<=0)) {     } } onClipEvent (enterFrame) {     if (_root.hitball.hitTest(_root.leftfouline)) {         trace("FOUL!");     } }

Any help is appreciated. Thanks.
Guy71173 is offline  
Closed Thread

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 12:10 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.