Recent posts by NineFiveThree on Kongregate

Flag Post

Topic: Game Programming / Problems with resetting

A sub class can do everything its super class can do and possibly even more.
But not vice versa.

You have an OnGround reference (testRemove), but you try to stick a DisplayObject into it,
That won’t work, because OnGround has more features than DisplayObject (say for example everything it inherits from MovieClip).

The DisplayObject cannot fullfill the role of an OnGround object that you try to fit it into.
You’d have to try to cast it to OnGrounds, but don’t do that, here’s why:

The core problem is that you use getChildAt().
You are abusing the display list as a datastructure, which leads to problems.

Instead, just put all your objects into an array.
You can iterate over it easily.

The line --childrenOnStage; is rather pointless.

 
Flag Post

Topic: Game Programming / Adobe flash pro + as3

Originally posted by shinekPL:

what language You used to write Your game?

Any of the 3 mentioned languages (javascript, java, actionscript 3) will allow you to create your game.
All of them will be suited as a beginner language.

What language you choose to write your game depends on the platform you want to target.

 
Flag Post

Topic: Game Programming / .bat file from swf

just use Air, it pretty much made the projector obsolete

creating a .bat file to execute it in order to execute other programs sounds pointless, just execute those other programs.

 
Flag Post

Topic: Game Programming / As3: Adding all movieclips on stage to an array

Originally posted by cod_warfare:

is this right?

for(i = 0; i < parent.mc.numChildren; i++) {
parent.mc.getChildAt(i);
}
//hittestfunction

why don’t you just try it?

If you are coding on the container that contains the mcs, there’s no need for parent.mc

 
Flag Post

Topic: Game Programming / Package system

The folder structure IS the package.
It should be

com / adobe / utils / AGALMiniAssembler.as

Where you put the com folder depends on you.
The best choice would be to create one directory where you put all external code.
You should tell your compiler that this is a classpath and it will find the classes.

 
Flag Post

Topic: Game Programming / Swapping Depths in AS3

First of all, if you want to group objects, just use DisplayObjectContainers to do that.
Create a Sprite object that is such a container for each of your “categories”.

depths are dense in AS3, so there’s no need to reserve a certain amount of depths, use containers to layer multiple objects

If you want to swap 2 children of one container, use these two methods:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html#swapChildren%28%29
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html#swapChildrenAt%28%29

If you compute all depth values of each object, you could also use:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObjectContainer.html#setChildIndex%28%29

 
Flag Post

Topic: Game Programming / Need help with error (as3)

if (levelData2D[i][j] == 5)
                {
                        b5 = new block5  ;
                        addChild(b5);
                        b5.x = tileSize * i;
                        b5.y = tileSize * j;
                }

yeah, copy and paste is a really cool thing and quite handy, but it generates code that’s hard to manage, because it is made up of several duplicated parts.
So let’s try something else, like this for example (untested, but you get the idea)

var block:DisplayObject = new getDefinitionByName ("Block" + levelData2D[i][j]) ;  //class names start with capital letter
addChild(block);
block.x = tileSize * i;
block.y = tileSize * j;

However, I’d pass the number to a single class and figure out what to do with the number in the class.

var block:Block = new Block(levelData2D[i][j]) ;  //class names start with capital letter
addChild(block);
block.x = tileSize * i;
block.y = tileSize * j;
 
Flag Post

Topic: Game Programming / Enable to access nested movieclip

Originally posted by moynzy:

or perhaps it’s not added to the display list, but flash should automatically add it to the display list, right?

If it wasn’t on the display list, you couldn’t see it.

The important thing is that just because something is a child of a DisplayObjectContainer, it doesn’t become a property of it.
That’s what the error exactly states: it cannot find the property “amode”

character.aMode

I’m not sure why the variable character is static, there’s no need to.
Class names start with a capital letter by convention.

public static var character:player;

This is not related to the problem, but try something like this:

private var _character:Player;  // the underscore helps seeing that this is a class wide know private variable

To solve the actual problem, I’d create a function in the player class that returns the coordinates that should be used for hittesting.
This way your hittesting code does not depend on the inner structure of your character.

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

Originally posted by moynzy:
 if(rightkey) {move the player to the right by 3 pixels and then move the container (container.x – 3) } 

Would this be the solution (You’ve said the solution many times, I know. But I don’t know how to implement it from your pseudo code to actual code)

Originally posted by dragon_of_celts:
Originally posted by NineFiveThree:


Move your player regularly within the container, then move the entire container (including the player) in the opposite direction.

In other words: when you move right 3 pixels, you would add 3 to player’s x then subtract 3 from container’s x.

yes

There’s no need to make every variable static.

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

Originally posted by moynzy:

I’m moving the the container

You are not moving the container.
I mean seriously, you just said yourself that you move everything inside the container.

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

Originally posted by moynzy:

It moves everything in the container apart from the player, and the player is in the middle.

I told you a dozen times why this is not a good idea.

Why don’t you just answer the two questions I asked?

Why do you start messing around with different parts of your code when one is failing but never try to actually understand what the problem is and fix it?

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

what is character?
what is player?

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

Originally posted by moynzy:

The player needs the name because you can pick 2 players. if you pick A , character = A, if you pick B, character = B. character is datatyped to a class called player, and A and B classes extend player.

And that’s exactly why you can have a single variable typed to player:

var player:Player;

if(type A chosen)
        player = new A();
else
        player = new B();

container.addChild(player);

also, what the dragon said.

If you ever post code again, please put it into pre tags so it looks like the code above.
You can read here
http://www.kongregate.com/pages/formatting
and here
http://www.kongregate.com/forums/4-game-programming/topics/39889-proper-forum-code-formatting-guide
how to do that.

Formatting your code nicely makes us sticking around and not giving up a lot more likely.

Also, give your classes proper names, A and B is not very descriptive.

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

As said, don’t use the names, that you provided in the name property.
You have instance names, so there’s no need to search for the object by its name property.

That’s like looking up the name of your mother in the telephone book to know her name.

I have no idea why you want to move an enemy.
I can’t even think of a way how you came up with that, because I told you in this whole thread that you should move the container so that you do not have to move all of its content individually (except the player)

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

congrats

You can set the name, but there’s no need to do it especially if you have instance names.
So don’t feel like you are forced to do it.

 
Flag Post

Topic: Game Programming / Keyboard command for AS3

Originally posted by moynzy:

I have never seen nor heard people use switch commands for player controls.

Is this more effective than Booleans, keyUp, and KeyDown listeners?

A switch statement is just another way of branching in your code.
If anything it is comparable to is/else statements.

Asking if it is more efficient than booleans doesn’t make much sense.
boolean is a type
with listeners you are probably referring to functions

apples, oranges and bananas

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

Originally posted by moynzy:

Okay, the problem is I can’t add the player to the container because I don’t know how to add the container to the display list (since the container isn’t added dynamically)

I have the feeling you just throw snippets of code together without knowing what they actually mean, I highly suggest you get a better understanding from the ground up.
Adding a container is nothing special, it works the same way you add any other display object, say the player for example.
Here’s a good read on how the display list works

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

Originally posted by moynzy:


this works fine, background is in container and I’m just moving what’s in the container, apart from timmy.

Cool, you pretty much ignored the whole thread, congrats.

Let’s try it one more time:
Move your player regularly within the container, then move the entire container (including the player) in the opposite direction.

I explained twice that it’s probably easier for you if the player is within the same container that’s moving, so its coordinate system is the same as everything else in the container which is the level.

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

make sure the container is added to the display list.

Again, you were talking about a level, which you should use as the container.

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

yes

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

As said, I suggest keeping the player in the container, so you don’t have to convert its coordinate system when interacting with the world around it.

Move the world (contaienr) so the character is centered (or wherever else you want him to be on the screen)

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

Originally posted by moynzy:

953, do you suggest creating a container and getting everything in that to move when the opposite way?

No.
Don’t move everything in the container but the container itself.
This way, you coordinate system stays the same.
(something at 5 / 5 is still at 5 / 5)

Put everything in the container.
Define somehow what part of this contaienr should be displayed, say for example the player should be in the center.
Now just move everything around as you wish.
When the player moved, move the container accordingly, so the player is in the center.

 
Flag Post

Topic: Game Programming / Creating a side scrolling platformgame in As3

My intentions is to scroll the level when the players moves right/ or left. What I don’t want to do is move the level when the player presses control keys.

So you want to move the level but don’t want to move the level?
Why don’t you want to move the level?

If you want to keep the player stationary, the easiest way to implement scrolling is to move everything else in the opposite direction instead, so move the level.

 
Flag Post

Topic: Game Programming / Isometric objects depth[as3]

Originally posted by a3lex33:

the best i found was as3isolib, but it was hard to understand and work with), so i am doing everything manually.

So that’s easier?
This looks promising and it states it sorts the depths automatically.
https://code.google.com/p/as3isolib/wiki/as3isolib_tutorial_002
I don’t know if it will handle the difficult cases you are facing. Give it a try.

The question if an algorithm exists or not depends on the circumstances. Concave shapes for example could surround another object, which makes depth sorting very difficult.
One solution is what shake suggested: make it tile based.

Post the texture you have problems with.

 
Flag Post

Topic: Game Programming / Isometric objects depth[as3]

What crappy isometric library are you using that it doesn’t even do depth-sorting for you?

Originally posted by a3lex33:

More, google tells me that there is no way to calculate isometric depth for object of any size.

What?