Announcement

User registrations are currently disabled due to high spam traffic.

#1 21/07/08 12:02pm

mental_atom
Regular Member
Registered: 11/06/08
Posts: 64
Website

Random side to side movemnt

shoudl this code work so that it moves to a random positon
i have this code:

Code:

onClipEvent (load) {
    _x = 0;
    _y = 0;
    speed = 40;
}
onClipEvent(enterFrame){ 
    endX = (random(480));
    endY = (random(272));
}
onClipEvent(enterFrame){
    _x += (endX-_x)/speed;
    _y += (endY-_y)/speed;
}

it almost worsk but the problem is it is always trying to move to a different place so it just kinda wobbled everywhere but doesnt get very far. can anyone help me with this problem?


[img]http://i25.tinypic.com/n4wlcm.jpg[/img]

Offline

 

#2 21/07/08 4:03pm

nothing
Moderator
Registered: 21/03/08
Posts: 389

Re: Random side to side movemnt

Increase speed maybe? It looks right...


[url=http://pspflashgaming.com/forum/viewtopic.php?id=1078]BioShock[/url] PSP|fPS-Factor Released|[url=http://www.p22server.hostwq.net/index.html]p22 Center[/url]

I'm starting p22 again.

Offline

 

#3 21/07/08 4:40pm

crimsonhotsun
Hardcore Member
Registered: 30/03/08
Posts: 96

Re: Random side to side movemnt

Is this LiveSwif? I see what the code does but I don't get what you're saying. If you could clear me up a bit on what you want and what the code is doing...


[img]http://img101.imageshack.us/img101/9094/20707804nc6.png[/img]

My humble forums: [url=http://hologram.zxq.net/forums/]VirtualWorldForums[/url]

Offline

 

#4 21/07/08 5:03pm

69corvette
That one guy.
From: Not Palmdale, CA
Registered: 01/02/08
Posts: 281

Re: Random side to side movemnt

Why are you using 2 enterframes for one clip?
As Crimson said, please clarify what you are trying to do.

Aww man what a waste of my 200th post... oh well.


[img]http://img221.imageshack.us/img221/8990/smallersigcopylb1.jpg[/img]

Offline

 

#5 21/07/08 5:10pm

mental_atom
Regular Member
Registered: 11/06/08
Posts: 64
Website

Re: Random side to side movemnt

ill post a preview tomorro when i get to a pc.


[img]http://i25.tinypic.com/n4wlcm.jpg[/img]

Offline

 

#6 21/07/08 5:23pm

nothing
Moderator
Registered: 21/03/08
Posts: 389

Re: Random side to side movemnt

He wants his thing to move side to side at random lengths. i thinks.


[url=http://pspflashgaming.com/forum/viewtopic.php?id=1078]BioShock[/url] PSP|fPS-Factor Released|[url=http://www.p22server.hostwq.net/index.html]p22 Center[/url]

I'm starting p22 again.

Offline

 

#7 22/07/08 8:56am

mental_atom
Regular Member
Registered: 11/06/08
Posts: 64
Website

Re: Random side to side movemnt

no i want it to move randomly. i dont know why i put side to side. i think someone changed it. but anway with that code it is trying to go to a random location permanaenlty. and this happens
http://www.resiststorage.org/images/ran … ena524.swf


[img]http://i25.tinypic.com/n4wlcm.jpg[/img]

Offline

 

#8 22/07/08 10:59am

Zuriki
Flash Dev (The Lazy One)
From: Manchester
Registered: 18/01/08
Posts: 755
Website

Re: Random side to side movemnt

Make it set a target area to move to then switch when it gets there.

If you want you can use 2 movieclips for practice.

Target movieclip:

Code:

_root.target.onEnterFrame=function()
{
if(_root.target.hitTest(_root.man)){
this._y = random(272);
this._x = random(480);
}
}
_root.man.onEnterFrame=function()
{
if(this._x > _root.target._x){
this._x -= 5;
}
if(this._x < _root.target._x){
this._x += 5;
}
if(this._y > _root.target._y){
this._y -= 5;
}
if(this._y < _root.target._y){
this._y += 5;
}
}

That should work (the code just goes on the frame, just make 2 movieclips with instances of target and man. No code on either).

I wrote this as I have just gotten up, so expect it to probably not work.

Last edited by Zuriki (22/07/08 11:04am)


[img]http://img134.imageshack.us/img134/9129/headerxt2.png[/img]
[url=http://zuriki.co.nr/project/traveller/][img]http://i28.tinypic.com/2vspafo.png[/img][/url]
[url=http://zuriki.co.nr]Zuriki - PSP Flash Games[/url]

Offline

 

#9 22/07/08 1:40pm

mental_atom
Regular Member
Registered: 11/06/08
Posts: 64
Website

Re: Random side to side movemnt

it works, but how can i make it so it keeps moving and changing position


[img]http://i25.tinypic.com/n4wlcm.jpg[/img]

Offline

 

#10 22/07/08 2:53pm

Zuriki
Flash Dev (The Lazy One)
From: Manchester
Registered: 18/01/08
Posts: 755
Website

Re: Random side to side movemnt

Mmm... that's what that does, no?


[img]http://img134.imageshack.us/img134/9129/headerxt2.png[/img]
[url=http://zuriki.co.nr/project/traveller/][img]http://i28.tinypic.com/2vspafo.png[/img][/url]
[url=http://zuriki.co.nr]Zuriki - PSP Flash Games[/url]

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson