Announcement

User registrations are currently disabled due to high spam traffic.

#1 12/07/08 7:21pm

lilmb
Serious Addict
From: Latvia
Registered: 22/06/08
Posts: 305

Problem with player rotation

Ok, i wrote this code: (actually copied from kirupa.com)

Code:

if (key.isDOWN(Key.UP)) {    
this._y -= walkSpeed;
    _rotation  =  0;
}   
if (key.isDOWN(Key.DOWN)) {    
this._y += walkSpeed;
    _rotation  =  180;
}
if (key.isDOWN(Key.LEFT)) {    
this._x -= walkSpeed;
    _rotation  =  270;
}
if (key.isDOWN(Key.RIGHT)) {    
this._x += walkSpeed;
    _rotation  =  90;
}

This code should rotate my sprite.
But, it doesn't. When I press left, right or down it just disappears and when I push up button he appears. Why is it happening?
I'm using Liveswif.

Thanks! smile

Offline

 

#2 12/07/08 7:44pm

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

Re: Problem with player rotation

As far as rotation is concerned, you need to have this._rotation instead of just _rotation. As for appearing and disappearing, it would help if I saw the rest of your code.


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

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

Offline

 

#3 12/07/08 8:39pm

lilmb
Serious Addict
From: Latvia
Registered: 22/06/08
Posts: 305

Re: Problem with player rotation

This is all code.
I just made a little moving script.
I aready tried this._rotation.
Result was the same. sad
I tried _root.player., too. It didn't work.
But i think that i will better make it as animation.
But, of course, if somebody could find out this code's glitch, i would be very happy! smile

Offline

 

#4 12/07/08 9:15pm

tenjimaru
Moderator
From: SD-CA
Registered: 30/03/08
Posts: 679

Re: Problem with player rotation

I dont know much about this software, but the AS should be the same or almost, as is Flash Mx 2004,make different sprites for each ArrowKey and use this code in the main mc or where you need the code.

Code:

if (key.isDOWN(Key.UP)) { 
this._y -= walkSpeed;
 this.goAndPlay (1);
}   
if (key.isDOWN(Key.DOWN)) { 
this._y += walkSpeed;
 this.goAndPlay (2);
}
if (key.isDOWN(Key.LEFT)) { 
this._x -= walkSpeed;
 this.goAndPlay (3);
}
if (key.isDOWN(Key.RIGHT)) { 
this._x += walkSpeed;
 this.goAndPlay (4);
}

[i]cookie Tenebra Crystallis.. Released!
Portable Fishing 2012 Released!
Find Them In The 'Flash Games' Section of The Forums[/i]

Offline

 

#5 12/07/08 9:33pm

lilmb
Serious Addict
From: Latvia
Registered: 22/06/08
Posts: 305

Re: Problem with player rotation

Ok, thank you, Tenjimaru and Crimsonhotsun! I am already making rotation with animations, as I said before. smile

EDIT: Ok, again problem, i think because of Liveswif.
Here is my code:

Code:

if (key.isDOWN(Key.UP)) { 
this._y -= walkSpeed;
 this.gotoAndPlay (2);
}   
if (key.isDOWN(Key.DOWN)) { 
this._y += walkSpeed;
 this.gotoAndPlay (2);
}
if (key.isDOWN(Key.LEFT)) { 
this._x -= walkSpeed;
 this.gotoAndPlay (2);
}
if (key.isDOWN(Key.RIGHT)) { 
this._x += walkSpeed;
 this.gotoAndPlay (2);
}

And the .swf file:
swf

So the problem is that the sprite has glitch, when pressing buttons, sometimes the legs move, sometimes, not.

It doesn't animate when i'm pressing button.

It happens even if i make each button animation. Now for all buttons it is one animation!

Hope you know answer! Thanks!

Last edited by lilmb (14/07/08 11:24am)

Offline

 

#6 17/07/08 11:45pm

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

Re: Problem with player rotation

I'm surpirsed the presented scripts even work...
it should be

if(Key.isDown(Key.Right)){ }

the "DOWN" in isDOWN needs to be "Down".

as for the rotation if the code is on the movieclip it should be "this._rotation" otherwise "MCName._rotation"


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

Offline

 

#7 18/07/08 12:23pm

lilmb
Serious Addict
From: Latvia
Registered: 22/06/08
Posts: 305

Re: Problem with player rotation

Ok, thx Corvette! smile

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson