BluePriest
470 posts
|
Topic: Game Programming /
Learn AS3 instead of AS2.
I think learning as2 helped me a lot in learning as3. Sure, I realized that things were pertty slow in as2, and when I siwtched to as3 some things were a lot easier, like removing things from an array. Demeaning people who use as2 by saying they cant program is not helpful in the least bit though. Its a great place to start to learn how to be a programmer. Easy start, and although it wont get you as far as youd need to be, it still starts you off.
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
Learn AS3 instead of AS2.
Originally posted by Senekis93:
But I’m a beginner and AS2 is easier…
False. The “AS2 is easier” argument is used by people who lack the
required skills to be a programmer. If that’s your case, you can use
tools like Stencyl, which don’t even require you to code and will run
faster than an AS2 application.
This statement is so… i dont know how to describe it.
Its easier BECAUSE you dont need as much skill
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
Learning to Add Multiple Levels?
A timer is the easiest way to do it imo. Just make a timer, and once timer1=10000 or however long you want the round to be, then round=2 and the new wave of enemies will come.
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
Addchild at same place as an instance
how would I modify my shootbullet functions x and y to just search for pt for its x and y coordinate? Im also unsure of where to add it in my Ship class. My initial thought was that it went in the Ship function, since it should only need to be loaded once, but when I do that, it says pt is an undefined property. So I stuck it in my move function which is where the enterframe event is called, and it doesnt give me the error, so I am guessing it goes there? I just want to make sure Im doing it right.
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
Addchild at same place as an instance
So I currently have it as
var pt = new Point(shipinstance.x, shipinstance.y);
pt=localToGlobal(pt);
shootbullet(shipinstance.pt, shipinstance.pt,20,20);
but my bullet is spawning at the bottom of the screen instead of at the location of the shipintsance.
I also tried doing something like
shootbullet(x + shipinstance.pt, y + shipinstance.pt,20,20);
but with the same result. Am I doing something wrong with setting the x and y point in the localtoglobal?
|
|
|
BluePriest
470 posts
|
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
Addchild at same place as an instance
eh, it didnt work. Ill probably just go back to doing it the old fashioned way of having 10 bullet classes. The rotation is just making it too complicated for my first game in as3. Thanks for the attempt. When I make a top down shooter instead of astroidsesque Itll be a lot easier. Trying to compile them all into 1 clip was a great idea, but its been taking me almost a week and this rotation is still messing it up.
|
|
|
BluePriest
470 posts
|
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
Addchild at same place as an instance
? Even if the ship is rotated, Im just setting it to the x position of the shipinstance. Thats why I dont understand. If I rotate, then the x position of shipinstance is different, so it should still spawn at it (well obviously its not, so im wrong, but I just dont understand)
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
Addchild at same place as an instance
I have a Ship class that has a shipinstance and shipinstance2 nested inside of it.
function shootbullet(a, b, m, n)
{
var bullets = new Bullet();
bullets.x = a; //x position the bullet will spawn at
bullets.y = b; //y position the bullet will spawn at
bullets.xSpeed = m;
bullets.ySpeed = n;
bullets.rotation = this.rotation;
stage.addChild(bullets);
}
if (numberOfBulletsVar > 1)
{
shootbullet(x + shipinstance.x, y + shipinstance.y,20,20);
}
if (numberOfBulletsVar > 2)
{
shootbullet(x + shipinstance2.x, y + shipinstance2.y,20,20);
}
I tried that, and they spawn right at the proper spot when my ship isnt rotated, but as soon as I rotate the ship, then it spawns out of posistion. Why, and how do I fix it?
|
|
|
BluePriest
470 posts
|
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
addchild(enemy) returning null. Solved, final quick effeciency question
by base class I’m assuming you mean the class that adds the enemy ship to the stage. that would be my main game class. I was following Molly’s as3 shooter tutorial on Kong to start off my game. the game class is the base class of my whole game. I’m not sure if that’s what you’re talking about or not though
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
addchild(enemy) returning null. Solved, final quick effeciency question
how intensive is the stretching and shrinking a movie clip? Because its the same movie clip, but different size?
@Aesica- IVe never done anything aside from classes extending a specific movieclip. How would the coding work for this? public class enemyclass extends ????? ? Im not sure what I would have it extend. And then have the specific enemy ships be public class enemyship5 extends enemyclass Im guessing that the specific enemies would extend the enemyclass.
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
addchild(enemy) returning null. Solved, final quick effeciency question
To show how similar the classes are… http://pastebin.com/JCqa5dNZ http://pastebin.com/4vLqc3Mp are 2 that the only difference is 1 achievement. http://pastebin.com/YS1G0UMU is the one thats a bit different because thats when it finally dies instead of going to a smaller enemy
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
addchild(enemy) returning null. Solved, final quick effeciency question
All but 1 of my enemy classes are the exact same except the movieclip. Well, 1 of them is a little different. It has an explosion that is called instead of creating more enemies. Is there a way to condense those down? Like perhaps instead of extending a movieclip first, it extends something else, and then that code is applied to 4 different movieclips?
EDIT
Oh wait, some of them have a few different achievements attached to them as well. They each have an individual achievement for killing that enemy once.
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
addchild(enemy) returning null. Solved, final quick effeciency question
I have 5 enemy ships. The Number 5 will spawn between 1-3 enemyship4s, the 4 will spawn between 1-3 enemyship3s, ect ect. Currently, all of them are using my old code before I did the random amount of enemies spawned.
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
addchild(enemy) returning null. Solved, final quick effeciency question
Moving the removechild did it thank you Ace. So heres a final question. Is the way I was doing it, or the way DrYoshiYahu showed more effecient? Im guesing his is, but I want to make sure before I change all of my enemy classes.
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
addchild(enemy) returning null. Solved, final quick effeciency question
ahh I seewhat you mean. I figured that since it was all in the same function order didn’t matter but you’re saying it does. at work now but ill give it a shot when I get home
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
addchild(enemy) returning null. Solved, final quick effeciency question
Originally posted by Ace_Blue:
I believe your problem is the stage.removeChild(this); line. Once you’ve removed this from the display list it no longer has access to stage, so any call to stage is going to generate an error.
My code used to look like this and work perfectly fine.
if (exploded == false)
{
var enemy = new EnemyShip();
enemy.x = this.x;
enemy.y = this.y;
enemy.xSpeed = this.xSpeed;
enemy.ySpeed = this.ySpeed;
addchild(enemy)
var enemy1 = new EnemyShip();
enemy1.x = this.x;
enemy1.y = this.y;
enemy1.xSpeed = this.xSpeed * -1;
enemy1.ySpeed = this.ySpeed * -1;
addchild(enemy1)
var enemy2 = new EnemyShip();
enemy2.x = this.x;
enemy2.y = this.y;
enemy2.xSpeed = this.xSpeed * 1;
enemy2.ySpeed = this.ySpeed * -1;
addchild(enemy2)
removeEventListener("enterFrame", enterFrame);
stage.removeChild(this);
Game.enemieskilled += 1;
exploded = true;
if (Game.miniach == false)
{
Game.updateach("Achievement Unlocked: Mini Monster");
Game.updateScore(1000);
Game.miniach = true;
Game.achMenu.mini.gotoAndStop(2);
}
if (Game.ship.ShieldPower == 1)
{
Game.updateScore(150);
}
if (Game.ship.ShieldPower == 2)
{
Game.updateScore(150*.7);
}
if (Game.ship.ShieldPower > 3)
{
Game.updateScore(150*1.3);
}
But i decided I wanted it to be random the amount of enemies that spawned. Since I stopped calling addchild immidiatly after though, it stopped working.
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
addchild(enemy) returning null. Solved, final quick effeciency question
I usually call the event like function createenemy(e:Event) so how would I do that when there is the abmn in there?
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
addchild(enemy) returning null. Solved, final quick effeciency question
I have almost everything added in my main class like im supposed to, I just havent been able to figure out how to add them upon the death of an enemyship at the enemy ships location. And If I add the createenemy function to the main class, then I havent been able to access it via my enemyship class when it dies
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
addchild(enemy) returning null. Solved, final quick effeciency question
I really like how thats much more compressed. I never understood how the (a,b,m,n) works before, but seeing it in the context of my code makes it very understandable. Unfortunately I still get the null error at the stage.addChild(enemy) , and then whenever I call createenemy (but thats due to addchld returning null so I guess its pretty much irrelevant)
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
addchild(enemy) returning null. Solved, final quick effeciency question
What am I not understanding?
function die()
{
if (exploded == false)
{
var enemy = new EnemyShip();
enemy.x = this.x;
enemy.y = this.y;
enemy.xSpeed = this.xSpeed;
enemy.ySpeed = this.ySpeed;
var enemy1 = new EnemyShip();
enemy1.x = this.x;
enemy1.y = this.y;
enemy1.xSpeed = this.xSpeed * -1;
enemy1.ySpeed = this.ySpeed * -1;
var enemy2 = new EnemyShip();
enemy2.x = this.x;
enemy2.y = this.y;
enemy2.xSpeed = this.xSpeed * 1;
enemy2.ySpeed = this.ySpeed * -1;
removeEventListener("enterFrame", enterFrame);
stage.removeChild(this);
Game.enemieskilled += 1;
exploded = true;
if (Game.miniach == false)
{
Game.updateach("Achievement Unlocked: Mini Monster");
Game.updateScore(1000);
Game.miniach = true;
Game.achMenu.mini.gotoAndStop(2);
}
if (Game.ship.ShieldPower == 1)
{
Game.updateScore(150);
}
if (Game.ship.ShieldPower == 2)
{
Game.updateScore(150*.7);
}
if (Game.ship.ShieldPower > 3)
{
Game.updateScore(150*1.3);
}
if (numberofenemies <= 1)
{
stage.addChild(enemy);// Error #1009: Cannot access a property or method of a null object reference.
}
if (numberofenemies > 1 && numberofenemies <= 2)
{
stage.addChild(enemy);// Error #1009: Cannot access a property or method of a null object reference.
stage.addChild(enemy1);// Error #1009: Cannot access a property or method of a null object reference.
}
if (numberofenemies > 2 && numberofenemies <= 3)
{
stage.addChild(enemy);// Error #1009: Cannot access a property or method of a null object reference.
stage.addChild(enemy1);// Error #1009: Cannot access a property or method of a null object reference.
stage.addChild(enemy2);// Error #1009: Cannot access a property or method of a null object reference.
}
for (var i in Game.list)
{
if (Game.list[i] == this)
{
Game.list.splice(i,1);
}
}
}
}
|
|
|
BluePriest
470 posts
|
Topic: Game Programming /
Collision, and Next Frame
what code do you have so far so we have something to work with
|
|
|
BluePriest
470 posts
|
|