ldstrumpet
141 posts
|
Topic: Game Programming /
Help with AS3
Also try using stage.addChild(enemy) instead of just addChild
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
Sound actionscript not working =(
If you look at Kongregate’s tutorial on actionscript 2 #8, page 2 (http://www.kongregate.com/games/Kongregate/shootorial-8), you will see that the
_root.mySound.attachSound(“name.wav”)
has the file extension on it, try doing that.
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
[ActionScript 2.0] How do I get my game to move when I drag it?
Well if your buttons arn’t moving like in SimCity there is just a side bar, they shouldn’t be in the movie clip and then you shouldn’t have a problem, but for moving buttons with the background you could just not put them in and move them the same as the background although that way is rather tedious and there is more then likely a better way.
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
Adding things dynamically
Thanks man, it works perfectly. Where did you learn all of this? I’ve read most of the Essential Actionscript 3.0 but maybe i’m missing the concepts.
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
Preloader
So, i’m trying to implement that, but it is just bypassing the whole preload and then playing the movie. Any suggestions?
public function Main():void
{
stage.addChild(mc);
stage.addChild(introMovie);
addEventListener(Event.ENTER_FRAME, checkFrame);
}
private function checkFrame(e:Event):void
{
if (introMovie.currentFrame == introMovie.totalFrames)
{
removeEventListener(Event.ENTER_FRAME, checkFrame);
stage.removeChild(introMovie);
mainMenu();
}
}
|
|
|
ldstrumpet
141 posts
|
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
Adding things dynamically
SuperMario: When doing it the way you supported, errors arise in the beginFill and end fill stating: src\HealthBar.as(23): col: 18 Error: Call to a possibly undefined method beginFill through a reference with static type flash.display:Shape.
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
ActionScript 2.0 or 3.0
Molly made an ActionScript 3.0 version of the shootorials which are found on this site as well. Here is the first one: http://www.kongregate.com/games/Moly/shootorial-0-actionscript-3
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
Really BIG Problem Level Select AS3
That is not AS2 it is AS3, i even used it to make my own level select thing. At least i made it AS3 it is not very hard all you need are a couple new brackets. My final usage of that code is just:
for(var i:int = 1; i <= numLevels; i++){
if (i <= levelsComplete) {
placeUnlockedButton(i);
}
else {
placeLockedButton(i);
}
}
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
Adding things dynamically
Thanks. So i’ve been working on making a health bard and this is what i got:
graphics.beginFill(0xFFFFFFF);
graphics.drawRect(14.5, -5, 50, 5);
addChild(healthBar);
healthBar.x = 14.5;
healthBar.y = -5;
healthBar.width = 50;
healthBar.height = 5;
healthBar.addChild(hb);
healthBar.scaleX = health / maxhealth;
graphics.lineStyle(1,0×000000);
graphics.moveTo(14.5, -5);
graphics.lineTo(65, -5);
graphics.moveTo(14.5, -5);
graphics.lineTo(14.5, 0);
graphics.moveTo(65, -5);
graphics.lineTo(65, 0);
graphics.moveTo(14.5, 0);
graphics.lineTo(65, 0);
What it does is that it makes a white rectangle at behind everything for the backdrop, it then adds a clip (green health) which is supposed to be what moves [health bar is a movie clip and hb is a graphic(i couldn’t figure out how to fill it, if you know please tell me)] and last it makes the border. The problem is, is that it only attaches the green health bar to the newest ship on the screen, and then if something else appears it disappears and attaches to the new one. Also, it doesn’t move (not as in x y coordinates but scaling) so what’s the problem?
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
[solved] AS3: How to make a simple button?
Hey, I was just wondering if there was a way to give these buttons a background fill easily. Also, would I have to give it a class and things to make it do something when you click on it or is there an easier way. Any ideas?
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
Noob question (AS3)
Or all you do is right click hit open with and then open with an internet browser.
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
[Solved[ for checking with null lists.
Okay, so i finnally figured out how to make it work. The semicolon was a problem but another arose which was they wouldn’t move at all because the list was never null. For future references and those who will need to know exactly the answer to the problem here is the final code:
if (EnemyShip.list != null) {
for (var i:String in EnemyShip.list) {
if (this.hitTestObject(EnemyShip.list[i])) {
fireBullet();
return;
}
}
}
if (this.x < 1950 ) {
this.x += speed;
}
}
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
[Solved[ for checking with null lists.
Well that is helpful in telling me what I already but thank you for reminding me as it is a good way to check. sBackground.x + 50 is 50 away from the left of the screen and as they travel from the right to the left they just keep going and going right past the 50. Also what should be happening is that they stop when they hit an enemy but they just keep going.
If i make the ‘else if’ just an ‘if’, it would work, but I don’t want them to move when they hit somebody, Any Ideas?
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
[Solved[ for checking with null lists.
@DeepClaw: How would i make it so it checks all of them?
I’m having trouble with this again. If i do it this way:
private function enterFrame(e:Event) {
if (FriendlyShip.list != null) {
for (var i in FriendlyShip.list) {
if(this.hitTestObject(FriendlyShip.list[i])){
FriendlyShip.list[i].takeDamage(10);
break;
}
}
}
else if (this.x > 50 + Main.sBackground.x); {
this.x -= speed;
}
}
The enemies by pass the else if statement and just always move, but if i do it this way.
private function enterFrame(e:Event) {
for (var i in EnemyShip.list) {
if(EnemyShip.list != null) {
if(this.hitTestObject(EnemyShip.list[i])){
EnemyShip.list[i].takeDamage(10);
break;
}
}
else if (this.x < 1950 + Main.mc.sBackground.x); {
this.x += speed;
break;
}
}
}
They move and stop moving at the right places, but they do nothing when there are no enemy ships on the screen.
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
[Solved] Changing Lists
Oh, that is a lot easier. Thanks
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
Question...
Code would be nice so we know exactly what is going wrong.
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
[Solved] Changing Lists
I’m baffled with this new occurrence with my AS3 code. In my code, I have it where you can move along the background by hovering over the side (Something like Battlefield 1944). I have it so the things on the map move to keep at their same place. This code works for a few ships, and then they randomly switch.
private function backgroundMove(e:Event) {
if (sBackground.x != 0 && mouseX < 30) {
sBackground.x += 10;
for(var i in EnemyShip.list){
EnemyShip.list[i].x += 10;
break;
}
for(var i in FriendlyShip.list){
FriendlyShip.list[i].x += 10;
break;
}
}
if (sBackground.x != -1400 && mouseX > 570) {
sBackground.x -= 10;
for(var i in EnemyShip.list){
EnemyShip.list[i].x -= 10;
break;
}
for(var i in FriendlyShip.list){
FriendlyShip.list[i].x -=10;
break;
}
}
else {
return;
}
}
So instead of move – 10 they move + 10 and vice versa. Any thoughts?
|
|
|
ldstrumpet
141 posts
|
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
[Solved] Events
In my AS3 code i have a tab that has a .3 alpha and then when you mouse over it it goes to .6 alpha, but I want it to go back to .3 when it’s not hovering. I’m not exactly sure the best way to do that.
public class Tab extends MovieClip
{
public function Tab(bmp:Bitmap)
{
addChild(bmp);
this.alpha = .3;
addEventListener(MouseEvent.MOUSE_OVER, onMouseHoverEvent)
}
private function onMouseHoverEvent(e:MouseEvent) {
this.alpha = .6;
}
}
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
[solved] AS3: How to make a simple button?
Ok so it was because I was adding it to the main instead of the stage, thanks.
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
[solved] AS3: How to make a simple button?
I must be really unobservant with something in my code because i’m not getting anything:
public function Main():void
{
sBackground = new Background(Bitmap(new BackgroundClass()));
stage.addChild(sBackground);
stage.addChild(minimap);
minimap.x = 390;
minimap.y = 10;
var text:TextField = new TextField();
text.text = “PushMe”;
text.width = 10;
text.height = 20;
text.autoSize = TextFieldAutoSize.LEFT;
var menuItem:SimpleButton = new SimpleButton();
menuItem.upState = text;
menuItem.overState = text;
menuItem.enabled = true;
menuItem.hitTestState = text;
addChild(menuItem);
menuItem.x = 390;
menuItem.y = 10;
stage.addEventListener(Event.ENTER_FRAME, backgroundMove);
enemyShipTimer = new Timer(1000);
enemyShipTimer.addEventListener(“timer”, sendEnemy);
enemyShipTimer.start();
friendlyShipTimer = new Timer(5000);
friendlyShipTimer.addEventListener(“timer”, sendFriendly);
friendlyShipTimer.start();
}
and yes 390, 10 is on the screen.
|
|
|
ldstrumpet
141 posts
|
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
[solved] AS3: How to make a simple button?
I’ve asked the same question here: http://www.kongregate.com/forums/4-programming/topics/64505-adding-things-dynamically. As you can see the text part was answered, and if you ever want to do music its there too, but as for the buttons i would like to know as well.
|
|
|
ldstrumpet
141 posts
|
Topic: Game Programming /
[Solved[ for checking with null lists.
So in my code (AS3) i’m checking to see if the enemies hit test with friendly ships and then they will stop moving and attack each other. Here is the code that I have for the enemies.
private function enterFrame(e:Event) {
for(var i in FriendlyShip.list){
if(FriendlyShip.list != null && this.hitTestObject(FriendlyShip.list[i])){
FriendlyShip.list[i].takeDamage(10);
break;
}
else if(this.x > 50 + Main.sBackground.x); {
this.x -= speed;
return;
}
}
}
But when the list is null (no enemies on the screen) they get stuck and don’t listen to any other commands. How can I change this?
|