Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Have you read thru the comments on the page you linked?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
May b it sounds stupid
just check that you attached the class to movieClip in library
Find more inspiration, events, and resources on the new Adobe Community
Explore Now