creeplover
424 posts
|
|
|
|
creeplover
424 posts
|
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Memory Management
For adding a new bird:
private function addBird():void {
if(birds.indexOf(null)==-1) {
birds.push(new Bird());
} else {
birds[birds.indexOf(null)] = new Bird();
}
}
Enter frame event:
for(var i:uint = 0;i<birds.length;i++) {
var b:Bird = bird[i];
b.update();
if(b.needsToBeRemoved) {
removeChild(birds.splice(i,1)[0]);
}
}
Will that work? It looks a bit odd to me, but I can’t tell.
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Memory Management
So I have a list of MCs (Birds) stored in an array.
var birds:Array = new Array();
birds.push(new Bird(x,y));
birds.push(new Bird(x,2*y));
...
When a bird travels off the screen, I need to remove it. Because the birds travel at different speeds, the array needs to have elements removed from anywhere in the array.
To remove the bird that traveled off the screen, I call (in the Bird class):
MovieClip(parent).removeChild(this);
This removes the child from the stage, but the object is not picked up by the GC because it is still in the array.
I don’t know how to remove the bird from the array because…
- I don’t know what element index number the bird is
- The element id can’t be stored in the Bird MC because that id changes when other birds are removed from the array
So my question is… How can I remove an element from an array if I don’t know where it is?
|
|
|
creeplover
424 posts
|
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Text Question
I have a textField and text in it. Wordwrap is enabled. Sometimes the text runs on to the next line and sometimes not. Is there a way to find out if it wrapped or not? (can I find the y position of the last character of the text)?
Also is there a way to have uniform spacing between all characters of the text?
|
|
|
creeplover
424 posts
|
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Shared Objects on Mobile?
Can mobile phones store shared objects?
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Reflection
Solved.
@lobstershow That only works for shapes, not objects.
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Reflection
Check your pms.
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Reflection
Yeah, but that is a messy way of doing it. It limits me to having a solid colored background. Thanks anyways.
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Reflection
How can I make an object have a reflection (under it) that starts at 100% alpha at the top of the reflection and fades to 0% alpha. I know how to do it with just shapes, but not whole objects.
Like this: http://www.winsupersite.com/images/reviews/front_row_01.jpg
Object
Top: 100% alpha
Bottom: 0% alpha
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
V-Cam and HUD
Make 2 objects
1 object as the background. Change the x,y to move.
1 object as the HUD. Don’t change x,y.
|
|
|
creeplover
424 posts
|
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
GotW #3 (China)
I’m leaving to China in an hour. Good luck all!
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Boost game ratings...
I’d say that rating are based on:
50% graphics
30% game-play
10% story
10% music
After playing your Sector 12 game, I’ll rate it like a common user.
Graphics: 25/50
Game-play: 10/30
Story: 5/10
Music 7/10
Total: 47/100 = 2.4/5 stars
Graphics: You have a poor style of beveling your objects, by adding white and black on the sides. The logo is good. The gun, robots, and scenery looks very unrealistic. You should try to go for a more cartoonish look.
Game-play: Very unoriginal. Movement is poor. Robots move poorly and are hard to shoot.
Story: Story is lacking, but you do manage to provide an intro before each level.
Music: Background music is okay, and matches the theme of the game, but most people don’t like hard rock music. Sound effects can get annoying.
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Date difference
Yup. It works. It has been 3484889906449 milliseconds since Jan 1st Year 0 AD
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Date difference
Infact, I used this with a recent project (a ticker).
//year,month (0 based, so I subtraced 1),day,hour (0-23),min,sec,ms
private var then:Date = new Date(2000,8-1,30,14,59,44,2464);
private var now:Date;
private var difference:Number; (because can be larger than int.MAX_VALUE)
public function Main() {
addEventListener(Event.Enter_Frame,onLoop);
}
private function onLoop(e:Event):void {
now = new Date();//updates to current time
difference = now.valueOf()-then.valueOf();
//traces ms difference between time.
//if you want difference in days, months ect, just divide
}
//NOTE: only works if both dates are after Jan 1st, 1970
|
|
|
creeplover
424 posts
|
Topic: Collaborations /
Storyline Writer
Show an example to prove your skill.
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Is it really worth it to switch to AS3?
It is 100% worth it. It makes everything much easier and more organized. You can do pretty much anything with AS3. It is really easy to learn and expand your vocab if you already know the basics.
http://gamedev.michaeljameswilliams.com/2008/09/17/avoider-game-tutorial-1/
^That tutorial will give you the basics. (although I don’t like using timers)
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Child Removing
I guess you cache them as bitmaps.
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Child Removing
How could that game have a few thousand objects?
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Child Removing
How large does it have to get? For most project I don’t think there are huge memory leaks. I only find a need for like 5 nestings in a single project at most, and I don’t see any significant lag after long game play. Like… Project>Game>Map>Hero>Gun is the most I usually need.
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
Child Removing
Just remove Warrior class. You don’t need to disassemble your hierarchy system.
|
|
|
creeplover
424 posts
|
Topic: Game Programming /
GotW #3 (China)
It looks like the GOTW is dying. Is anybody going to participate in this one?
|