00:00
00:00
Newgrounds Background Image Theme

Almost-Ichabod just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Problem with code.

402 Views | 2 Replies
New Topic Respond to this Topic

Problem with code. 2016-10-20 12:39:29


Hi, my name is Abcight and I'm developer of game called "throw" (Game avaiable only as beta for betatesters).
Game is created using ActionScript 2.0 in Flash 8.

My question is, if someone could help me with throwing code.
What do i mean? i man that if you drag movieclip called "Ball" it just follows your mouse until you drop it.
Pretty simple code:

on(press){
if(_root.ThrowZone.hitTest(this)){
startDrag(this);
}}

on(release){
if(_root.ThrowZone.hitTest(this)){
stopDrag();
}}

I also have simple gravity code set up, but i rather not to show it, since it is not "that" needed.
I want it to throw the "Ball" as you release movieclip, i mean that it will go straight up with different
speed depending on how fast you moved it before you released it, i also want it to get slow in and slow out as it gets up.
I have tried covering my Gravity code a bit, changing it and reversing it, reversing psychics but then it will
go up same way no wonder how you throw it.

If you really need to test the game in order to see how it works, tell me in comment, and i WILL put link to it in thread.

Response to Problem with code. 2016-10-30 11:21:00


//ball_mc
ball_mc.onPress = function()
{
ball_mc.startDrag();
};

ball_mc.onRelease = function()
{

ball_mc.stopDrag();
};

Response to Problem with code. 2016-10-31 12:26:51


> flash 8
> 2008 + 8

You'd have to use a mouseMove event and check the delta x and y positions. That way, if there's any slowdown while dragging, the old_x and old_y will be very close to the new_x and new_y; a separate onRelease event will have a "released" boolean flag set to true (which is set to false whenever an onPress occurs).

An onEnterFrame, or onClipEvent(enterFrame) will check periodically if the ball's released flag is set to true, and if it does, then increase / decrease its x and y by the x and y velocity (= difference between new_x and new_y, and old_x and old_y respectively).

Also, the gravity will have to modify the y_velocity, which will in turn modify the ball's y, instead of having the gravity modify the y position of the ball directly.


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature