The McLeodGaming forums were permanently closed on April 30th, 2020. You are currently viewing a read-only archive.
View unanswered posts | View active topics It is currently Fri May 15, 2020 5:39 am

Forum rules


IMPORTANT

This Forum is for Flash related questions ONLY! Do not ask questions about spriting, Game Maker, Photoshop, or anything else not related to Flash.



 [ 3 posts ] 
[Request] Flash AS2 code help 
Author Message
User avatar

Joined: Mon Aug 11, 2008 6:56 am
Posts: 469
Location: not so superhappy fun fun land....
ok, I have this spiky ball character, instead of walking. I want him to roll.
I have a code:
Code:
onClipEvent (load) {
   gravity = 5;
   speed = 5;
   spin = 0;
}
onClipEvent (enterFrame) {
   gravity++;
   _y += gravity;
   if (Key.isDown(Key.LEFT)) {
      this._x -= speed;
      if (spin<10) {
         _rotation -= spin;
         _rotation--;
         spin++;
      }
      if (spin>10) {
         _rotation -= spin;
         _rotation--;
         spin--;
      }
   }
   if (Key.isDown(Key.RIGHT)) {
      this._x += speed;
      if (spin<10) {
         _rotation += spin;
         _rotation++;
         spin++;
      }
      if (spin>10) {
         _rotation += spin;
         _rotation++;
         spin--;
      }
   }
}

Now, for some reason, when I press left or right, it rotates for a little bit but then stops. Could some one help? Thanks!

_________________
Image

ashante08 wrote:
We argue, we try to understand each of our problems, we argue some more, rinse and repeat


Thu Jul 23, 2009 1:51 pm
User avatar

Joined: Wed Apr 29, 2009 11:28 pm
Posts: 323
Location: Nowhere, Antarctica
Gender: Anime Girl
Skype: Evilagram
For one, the whole thing is coded really awkwardly.

Why don't you just have the left and right keys change the spin and then apply the spin to the object?

And what's the point of the gravity at all?

I don't have flash on me so I can't test s***.

_________________
Image

Style [Stayl] (n) - One's unique and personal method of defacing a perfectly good piece of paper.

READ THIS: http://ipgd.freehostia.com/copypasta.html


Thu Jul 23, 2009 9:48 pm
User avatar

Joined: Mon Aug 11, 2008 6:56 am
Posts: 469
Location: not so superhappy fun fun land....
Evilagram wrote:
For one, the whole thing is coded really awkwardly.

Why don't you just have the left and right keys change the spin and then apply the spin to the object?
And what's the point of the gravity at all?

I don't have flash on me so I can't test s#%$&.

Thats probibly were I messed up. Thanks!
btw the gravity is for something. When the spike guy rolls off a cliff... whatever. Thanks again!
EDIT: just realized that I already have it to spin the object... It spins the object, but only for a little bit... I'd like it to continuously spin. What I did with my code is that I have the spin set to zero, so when Left/right is pressed, it spins slowly, then faster (acceleration!). once it gets to the speed I want it to, I made it that if the spin speed gets above 10, that it equals ten, so it doesn't go faster. When I try it out, it starts slowly, then once it gets to my desired speed... it stops. Sorry for the wall of text, just trying to elaborate for better help.

_________________
Image

ashante08 wrote:
We argue, we try to understand each of our problems, we argue some more, rinse and repeat


Mon Jul 27, 2009 1:50 pm
Display posts from previous:  Sort by  
 [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.