Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Why wont my ship move right?

Guest
Apr 26, 2011 Apr 26, 2011

I am following this tutorial and i have got to step 9.

http://www.kongregate.com/games/Kongregate/shootorial-1

I have made a file called Ship.as with this code in.

class Ship extends MovieClip
{
    var speed;
   
    function onLoad()
    {
    speed = 10;
    }
   
    function onEnterFrame()
    {
    if (Key.isDown(Key.RIGHT))
    {
        _x = _x + speed;
    }
   
    }
}

When i test the SWF nothing happens. The ship just sits in the top left corner doing nothing. I am getting no errors so can anyone help me fix this?

Thanks.

TOPICS
ActionScript
654
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 27, 2011 Apr 27, 2011

Have you read thru the comments on the page you linked?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 30, 2011 Apr 30, 2011

if you can not find what is wrong in that code you could use this instead

put this inside the movie clip

speed= 5;


onEnterFrame= function(){


if(Key.isDown(Key.RIGHT)) {
    this._x+=speed;
        }

}

or if you want the code on the frame then

speed= 5;


onEnterFrame= function(){


if(Key.isDown(Key.RIGHT)) {
     instancename._x+=speed;
         }

}

change the bit in red to your instance name of the movie clip you are trying to move

hope this helps

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 05, 2011 May 05, 2011
LATEST

untitled.JPG

May b it sounds stupid

just check that you attached the class to movieClip in library

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines