I am trying to make a “Achtung! die kurve” – like game in Actionscript 3.0.
So far I’ve done the movement of one of the ‘worms’, and it works alright.
I wanna divide it into different class files, but I can’t seem to get it to work.
I have a .fla file and 4 .as files. So far I only have code in two of these. When I put all my code directly into the fla file, it works perfectly fine, but when I put it into my player class, it won’t ‘add the child’ to the stage.
Here is my player .as file: http://pastebin.com/hZSxT9cu
the reason why I commented the addChild, is because I wanna do this in my mainFile.as
this is from the main file: http://pastebin.com/TAwUYrTU
I’m not quite sure how to call it in the main file, so I’m guessing that this would be the issue.
All the files are named and placed correctly in the same folder, and flash says that each of my .as files are targeting the .fla file, so this doesn’t seem to be the issue.
Any help is much appreciated.
furthermore, if anyone knows how I can change the speed of my sprite, that would be awesome! Can’t seem to get this to work either.
Best regards
Jesper
Looking at the game you reference, it’s obvious that you’re going to need some collision detection. This tutorial on pixel-level collision detection might be useful to get you started.
With your current setup, the only way I can see to increase the speed of the drawing would be to increase the frame rate in your fla.
You can’t add the player instance(s) as a child in your main class because currently it does not have access to it. Actually, it’s very inefficient to create multiple sprites within your player class. A more efficient approach would be to draw your rectangles directly within the graphics instance of your player instance.
I think the following might be a good starting point for what you’re trying to do. Again, I’ve included some comments which I hope will explain what I’m doing.
Set this as the document class in your fla:
}
And include this file in the same directory as the fla: