Quote:
Originally Posted by neznein9
Learn tweens first.
Printable View
Quote:
Originally Posted by neznein9
Learn tweens first.
huh? composition is not very complicated, is it?
edit: tweens: i read something about them, but honestly, is it a good idea to use them? they seem very short term problem solvers, or am i wrong? i don't think i will be able to use them very flexibly.
this is getting oftopic: compositions do not really have to do much with performance, neither really have tweens impact. Either you use them or you dont,- its fare more a design decission. This discussion feels abit like elementary school of flash.
On a sidenote but back onTopic: scripted tweens however can differ a hell lot performance wise if you dont stick to the bloated default classes but instead eiter code your own using getTimer or pick one of dozen available tween classes.
In most projects I usually code all tweens myself as it reduces the code and increases the performance for what I need it for.
ok
back on topic: how much ram does an object use? does the amount of methods increase this? or only the amound of fields?
An object uses exactly a megabyte of ram, plus 472k for each field.
seriously though.
what i meant was really: what detirmines the amount a of memory an object takes?
it really doesnt matter ,- what matters however is the amount of video or image ram that is used- so better watch out for them and like mentioned earlier ditch components as they can eat up to be loaded memory as well.
In as3 you can diplay the used ram
but again it does not have much to do with performance but rather stuff like garbage collection, preloading and dymainc asset loading.PHP Code:var mem:String = Number( System.totalMemory / 1024 / 1024 ).toFixed( 2 ) + 'Mb';
trace( mem ); // eg traces "24.94Mb"
And as for classes or functions,- just code smart and you wont have to worry that much for performance or bloated bytes. Only very complex projects really require thoughts on that matter.
when you have an if else statement, and in a particular case the else statement is executed, how much will the code placed after the if statement affect performance? because the processor has to go through it until it finds the else statement, right?
PHP Code:if (true)
{
//1000 lines of code
//how much will these lines of code slow down the execution?
}
else
{
doWhatever();
}
The length / contents of the first if don't make any difference, as in byte-code it'll just branch to the else check ( Like it would in any language ).
Your only speed lose is if the first conditional is false more often than it's true, that's why you should order conditionals in the order in which they're more likely to be called, although in the grand scheme of things it's not even worth worrying about.
Squize.
but branching to the next else statment takes a little bit of time, doesnt it? because he has to move thourgh the bytecode checking if he's reached else yet, right?
ps.
is there a big perfrmance difference between:
andQuote:
if (myObject is myClass){}
and then define varClassname in MyClass as " MyClass"Quote:
if (myObject.varClassname = "MyClass")
Im pretty sure the compiled code stores that info in tables, so it's not "searching" for the next 'else'. It just jumps to the next else in the if code table
"because he has to move thourgh the bytecode checking if he's reached else yet, right?"
No, the byte-code adds a branch when it's created, eg
conditional check
branch if it's not equal label_a
//...
label_a
//....
As to the new question about classes, I don't know off the top of my head, or care to be honest.
It's such a moot point that adds so little at all to the run time of a game that even at my most anal when we were doing all this with F5/6 did anyone care about that even then.
Sorry, but it's a question of priorities. If you've got a for example a brute force collision system in place then that alone will negate any short hand speed ups to the actual code, as I'm sure has already been said in this thread before.
Squize.
well the point is i have to do those if statements about 2500 times every 25 millisecs or so, and then alot more. so i'd figure it would probably have it's effect.
but ok i'll just focus on other stuff.
Could I ask why ? That seems really intensive, like a path finder or a 3D engine type intensive.
Squize.
AI every object has to check other objects. but i'll make it more effective, so that they only check nearby objects for danger etc, but right now it has to check allot.
Oh I see.
Like I said a couple of posts ago, avoid brute force methods as they take so much cpu time, and you seem to be aware of it so all good.
You should find that once you've nailed the main routines and got them running quickly that it won't even be worth your while to worry about the smaller things.
Squize.
yeah.
i just got another problem.
i have a function that is called when you press a key:
andPHP Code:private function keyPressed(e:KeyboardEvent):void
{
if (Boolean(keysDown[e.keyCode]))
{return;}
keysDown[e.keyCode] = true;
switch (e.keyCode)
{
case (LEFT)://arrow-left
///trace("left key pressed");
kine.setHSpeed(-SPEED);
//leftDown = true;
break;
case (UP)://arrow-up
//trace("up key pressed");
kine.setVSpeed(-SPEED);
//upDown = true;
break;
case (RIGHT)://arrow-right
//trace("right key pressed");
kine.setHSpeed(SPEED);
//rightDown = true;
break;
case (DOWN)://arrow-down
//trace("down key pressed");
kine.setVSpeed(SPEED);
//downDown = true;
break;
case (SHIFT)://Shift
trace("shot!");
weapon.shoot();
break;
}
but when i press them alot , the fps goes down. and you can see the spaceship shake even if u hold only one button. it doesnt go fluently, even though the fps remains about 50-55fps when only pressing one button.PHP Code:stage.addEventListener(KeyboardEvent.KEY_DOWN,keyPressed,false,-2);
how is that possible?
am i correct, that memory allocation (and deallocation???) is relatively a veery slow proces?
Memory allocation and deallocation will always be slow processes, however in flash it won't be as much of an issue because it is both slow to begin with and has garbage collection.
what do you mean? you can use object pools to solve the problem. and that significantly increases performance, if you have to make new objects and delete them all the time.