Under rating threshold (hideshow)
Why did the ship movieclip have to be registered with the dot in the middle but the background has the dot registered at the top left. What does that do?
Under rating threshold (hideshow)
If your ship flying off the screen bothers you, try this: You can put in this little line of code to your "Ship.as" file anywhere in the "onEnterFrame" function. Type: if(_x<20) { _x = 20; } ....for example, this will prevent your ship from flying off the stage on the left side. You can do other ones too (replace x with y to prevent flying off the top and bottom) play with the numbers till you get a boundary you are happy with :]
Under rating threshold (hideshow)
For some reason I can not get a seamless loop. When I set
if (_x < -2110)
{
_x = 0;
}
It sill waits till it gets to the end of the backround before resetting. I even tried putting 4 backrounds next to each other, so it continues to 8440 pixles, but it still does not reset at 2110. It scrolls through the whole backround getting to the end and going blank before resetting _x = 0; no matter how I try and tweak it.
Under rating threshold (hideshow)
Ok im really confused. I have a decent understanding of the codes, but in if(_x < -2210. So 2110 is th width of the BG. Mine is custom made and I made the width of the custom 2110 as well. I have all the codes down correctly. But when I play it, the BG only loops once. What am I doing wrong.
My full BG code is:
----------------------------------------------------------------------------
class Background extends MovieClip
{
function onEnterFrame()
{
_x -= 1;
if(_x < -2110)
{
_x = 0;
}
}
}
--------------------------------------------------------------------------
Help anyone???
Under rating threshold (hideshow)
Brilliant tutorial for the absolute basics. I was struggling to find a tutorial that actually explained each command instead of just telling me what to write, but this is perfect for the beginner to learn not copy :D
Under rating threshold (hideshow)
Also, i am trying to make it use WASD in stead of the arrow keys, i know, that was last shootorial but i dont care. Instead of the "LEFT" keycode, i put A, but it doesn't work, says "A is not a valid keycode" and doesnt work. What ore the keycodes for letters? KEYW? KEYA? or just W? A?
Under rating threshold (hideshow)
nah reading is the only thing you need to do, understanding the whole codes from the start from zero knowledge ain't that easy. this site just need more people that READS
Under rating threshold (hideshow)
I got all the way through frame 5 of the tutorial, and when I tested the movie as suggested my ship flew to the left instead of the background. I still have full control of the ship with the arrow keys, though. I'm sure there's something I've missed or not done right, but for the life of me I can't figure out what it is. The code that I have is exactly the same as in the tutorial. Can anybody help me?
Under rating threshold (hideshow)
Ok, fixed the ALL (ship and background) moving stuff.
My error was a question of hierachy.
Layer1 -> ship /background (both inside layer1). The right way is 2 DIFFERENT Layers from the root and NOT both Inside the Root.
In case of doubt, click on the Scene 1 title if u see only 1 layer ... thats the problem, u need to see 2 layers (ship and background) as unique items.
Under rating threshold (hideshow)
@tyugn did you made sure the framerate is 30 FPS?
Other wise come check the Game Development Room (GDR) once in a while, people will help you there.
Under rating threshold (hideshow)
My ship isn't moving when I try to test. Here is my code.
class Ship extends MovieClip
{
var velocity;
function onLoad()
{
velocity = 10;
}
function onEnterFrame()
{
if (Key.isDown(Key.RIGHT))
{
_x = _x + velocity;
}
if (Key.isDown(Key.LEFT))
{
_x = _x - velocity;
}
if (Key.isDown(Key.UP))
{
_y = _y - velocity;
}
if (Key.isDown(Key.DOWN))
{
_y = _y + velocity;
}
}
}
Under rating threshold (hideshow)
@bhattarai333 I know how to fix your problems, First, the Background.as file must be where your .fla file and Ship.as file are! Second, your background code should be:
class Background extends MovieClip
{
function onEnterFrame()
{
_x -= 1;
if(_x < -2110)
{
_x = 0;
}
}
}
the "Statement block must be terminated by '}'" error comes because you didnt put a '}' at the end of the code. and the "The class 'Background' needs to be defined in a file whose relative path is 'Background.as'" message comes because the Background.as isn't in the same place as the .fla file or in the code you put ackground instead of Background!
AND you get the "The class or interface 'Backround' could not be loaded." error because in the Background Movie Clip Properties, you put the Linkage Identifier: Backround and the Class: Backround instead of Background.
There you go!
Under rating threshold (hideshow)
If you want the background to loop properly, here is the code.
class Background extends MovieClip { function onEnterFrame() { _x -= 7; if(_x < -2110) { _x = 2100; } } }
The tutorial only makes it loop once.
Under rating threshold (hideshow)
I cannot get the bg to scroll (stuck on p.5) 'the class and interface could not be loaded'.
Followed everything in the tutorial paying attention to CAPS LOCK and s p a c i n g , and everything is stored in the same folder. When the ship moves, ther background moves with it.
Under rating threshold (hideshow)
Myself I did something simple - instead of adding extra graphic into the already created background i just made a change in "if" function so it moves to "_x = 600" instead of "_x = 0" - still looped, however with a white break, but the city appears in normal way.
Under rating threshold (hideshow)
To those whose backgrounds don't scroll:
When you first set the background as a symbol, did you move the registration to the top left corner? The center is the default, and it's wrong. Redo the symbolizing but make sure that when you see the 3x3 grid of tiny squares, the top left is black. If not, click it.
When you copied the background image, did you do it right? Make SURE you followed page eight (step 1) very closely. Simply adding another instance of Background doesn't work, for some reason.
Hope this helps!
Under rating threshold (hideshow)
okay, i've been doing well in all fo the other shootorials except this.
First: I have CS5.5 because CS3 is old and cant be downloaded anymore, and i think that might be a cause to my troubles
My problems are:
My background moves with my ship. I press left, it goes left too, press up, it goes up too etc.
It still scrolls but it also follows my ship.
Second, I cant get the Background to get the seamless Background, it gets the white area on the left of the screen after the picture is done. I did all the things the tutorial said, but as i said, i have CS5.5 so i think thats the problem.
Under rating threshold (hideshow)
Symbol=Background, layer=Layer 1, frame=1, Line 1 The class or interface 'Background' could not be loaded.
if you're having this kind of error.
check the name of your Action Script files.
in this tutorial all of it start with a capital letter.
Under rating threshold (hideshow)
uhh, my ship doesnt have a transperent back... it is a PNG but its got a white rectangle surrounding it. how do i get rid of that part?
Under rating threshold (hideshow)
Here's a quick upgrade to the code that will make the background a bit more interactive. Just make sure to move the background down a few pixels first (you'll see why):
class background extends MovieClip
{
function onEnterFrame()
{
_X -= 2
if (_x < -2110){ _x = 0 }
if (Key.isDown (Key.RIGHT)){_x -= 3 }
if (Key.isDown (Key.LEFT)){_x -= 1}
if (Key.isDown (Key.UP)){_y += 1}
if (Key.isDown (Key.DOWN)){_y -= 1}
}
}
Under rating threshold (hideshow)
@narfnin
make sure you didnt group the backgruond with the ship lol
also
make sure the background scroll speed is diff than the ship scroll speed XD
hope dat helps!
Under rating threshold (hideshow)
Here's the thing. These tutorials aren't correct. They give misleaded information about the code its self leading you to believe that certain things don't belong. I spent an entire day trying to figure out why the ship wouldn't go right when I pressed the right button but it just so happens that the code was wrong. It leaves important parts out as well such as the fact that you HAVE to save before you test or it won't work.
Though they do provide you with the basic script. You might have to do a little bit of fixing but the scripts work if you figure out the problem.
Under rating threshold (hideshow)
k I figured it out, the picture wasn't lined up when I converted it into a movieclip. I deleted it and converted it again and that fixed it. Still curious if you can fix it without deleting it though.....
Under rating threshold (hideshow)
"ugh. background class cannot be found even though it is in the same folder. any help?" Save the actionscript file as Background.as (if you registered the background with symbol and class Backgroud)
Under rating threshold (hideshow)
If you have errors always save. after saving you will see that if you made everything alright, it will work just fine :)
Under rating threshold (hideshow)
@Emilade , first, is the code on your "Ship Class" Coding? if not, was the "background class" coding applied to your ship?
Under rating threshold (hideshow)
PLEASE message me if you have the answer to this. There is a random ass white line in front of my ship. How do I get rid of it?
Under rating threshold (hideshow)
need badges :D
lol :)
i'm starting this tutorials :) thx a lot very useful ... not detailled but it is a good start and a push to search more on the net thx a lot :D
Under rating threshold (hideshow)
@euanstevenson
I have the exact same problem. I'm using CS5 and whenever the ship moves so does the background. All of my code is right and I can't figure it out.