Be a Supporter!
Response to: Sound on when movieclip is in zone Posted July 22nd, 2010 in Game Development

Yes, first apply a drag and drop code to one of your MCs and when they hitTestObject (hitTest in as2) eachother, play sound.

But it will loop the sound as long as your MC stays over the other one, if you want it to play just once - make a new variable "isHit" which is 0 by default

if ( isHit == 0 && mc1.hitTestObject(mc2)){
// play sound script here
isHit = 1
}

if ( isHit == 1 && !mc1.hitTestObject(mc2)){
isHit = 0
}

I didn't test it but it should work, good luck!
Note: it isn't the actual code above, it is the logic you should follow.

Response to: AS 3.0 personality quiz help Posted July 22nd, 2010 in Game Development

Use variables or arrays to keep track of answers.

The code seems to be fine, make sure you only have it once (you don't need to rewrite the code again), also why not use nextFrame(); and prevFrame(); instead of currentFrame +- 1?


So I created a small platformer prototype with rectangle ground, and now I want to try making a platformer with curved ground (like some flash games had their ground drawn with brush tool).

How do I do that? I don't need the code, I want someone to explain how does this work, what is the logic behind that. Then I'll try to code it myself.

Thanks in advance.

Response to: Accerlation Plus Enemy Spawn Posted July 21st, 2010 in Game Development

I accidently said that you should add speed to car.x, you should instead deduct it from bg.x (bg.x-=speed)
Oh and as for enemies, just do the same you do with background, enemy.x-=speed

Response to: Accerlation Plus Enemy Spawn Posted July 21st, 2010 in Game Development

At 7/21/10 11:49 AM, YoinK wrote: xKiRiLLx, that concept makes sense... but how would you code such a concept?
do you know of really good websites on learning code?

http://www.newgrounds.com/dump/item/8378 661075746aa3da29d8b3b451b1a2
this is actually an animated loop that gets accelerated... but not exactly what I want... I want it to be at a complete stop and accelerate if you hold right.. decelerate if you let go of right and eventually completely stop if you let go of right. And since this concept is animated in the frames already... it would probably make it tough to code the enemies that i want to put in place that will also be accelerated.

Is your background animated right now?

It shouldn't be... as I said, you need to split it into 3 parts. I might have misunderstood you on that though.

Say, there are 3 blocks of background that look like 1 landscape together, each block's width is 300.

[ 1 ] [ 2 ] [ 3 ]

So at the beginning [ 1 ] block's x is 0 (assuming its registration point is on the far left, at the very edge of the background block), [ 2 ] has an x of 300 and [ 3 ] - 600
At this moment, [ 3 ] is unseen (we assume that the stage width is 500)
Car starts to move, and all blocks are moved left. As soon as [ 1 ]'s x hits -300, change it to 600 (putting it in front of [ 3 ]) And so on with every next block!

To make speed decrease:
Make an enter_frame event for acceleration:

onClipEvent(enterFrame){
if (right_key_is_pressed && speed<10) {
speed+=2
}

car.x+=speed

if(speed>0){
speed--
}
}

The code above handles the acceleration and slowing down, as it is constantly slowing the car down (if the speed is bigger than 0) and gaining speed only when you press right.

As for learning to code, I'd say books would be the best option. You can download flash programming books from adobe site (as3, not so sure for as2)

I also write a blog with tutorials, but it's as3 (I really recommend changing to as3)

Hope I helped ;)

Response to: Accerlation Plus Enemy Spawn Posted July 21st, 2010 in Game Development

Instead of making the background into an animation, splice the whole background into smaller parts and then just move those, for example you have 3 parts:

[ 1 ] [ 2 ] [ 3 ]

The player drives and passes the first block, as soon as it goes out of stage it goes to the end

[ 2 ] [ 3 ] [ 1 ]

And so on, then you can apply acceleration!

Response to: Accerlation Plus Enemy Spawn Posted July 21st, 2010 in Game Development

Make a "gospeed" variable (default = 0) that increases or decreases (depending on which direction you're going) when you go left or right. The background's (and enemies') X coordinates are updated every frame (bg.x+=gospeed or something)

Here's the pseudo-code for accerlation (pseudo because I work with as3 and might make a mistake in as2):

var gospeed:Number = 0
var maxaccel = 6

onClipEvent(EnterFrame){
if (user_holds_right && gospeed < maxaccel){
gospeed+=2}
if (user_holds_left && gospeed > -maxaccel){
gospeed-=2}
if (gospeed>0){gospeed--}
if (gospeed<0){gospeed++}

bg.x+=gospeed
}

And to those that said "noone will make a code for you, do it yourself", OP didn't ask for the code directly, he just needed help explanation. If you have nothing better to contribute, don't go to this forum, as it is here to help people. Some people indeed do ask others to make games for them, but this isn't that situation.

Response to: Need help one more time... Posted July 20th, 2010 in Game Development

Plus you only need to define the sound variable and the function with listener only once (like the gentleman above me said), sorry I didn't read it well enough the first time

silly me
Response to: Need help one more time... Posted July 20th, 2010 in Game Development

You forgot to put { and } in the if statement

stop();

stage.addEventListener(KeyboardEvent.KEY _DOWN, downKey);
function downKey(event:KeyboardEvent){
if(event.keyCode==32){
play();
snd.play();
}
}

Good luck!

Response to: AS2 :: Flash pop-up window Posted July 20th, 2010 in Game Development

The example from kirupa works in IE for me...

Response to: Seemless music looping in AS3? Posted July 20th, 2010 in Game Development

I know that mp3's don't loop too well and have a second delay after end, it could also be the track itself that has a little pause in the end...

Try using the .wav format of the same sound, but as far as I know it is only possible to load wav's from your library (not external files) correct me if I'm wrong.

Response to: AS3 Image load Posted July 20th, 2010 in Game Development

At 7/20/10 06:19 AM, captinx wrote: Hi,

I am really new to AS3 and am finding it much harder to understand and use.

I am trying to get an image to be loaded in and resized and sent to the back so that everything else is on top of it.

now here is the code i am using:

// LOADS IMAGE IN
var imageLoader:Loader = new Loader();
var image:URLRequest = new URLRequest("http://www.blueidea.com/arti cleimg/2006/08/3904/images/image-2.jpg")

;

imageLoader.load(image);
addChild (imageLoader);
imageLoader.x = 0;
imageLoader.y = 0;
//imageLoader.width = 500; this does not work
//imageLoader.height = 260 this does not work
// LOADS IMAGE IN

So everything loads fine but the image is at the front of the screen so you can not see anything behind it, and it does not resize.

Please help thank you very much

Eli Stone

Use depths to send it to background:

setChildIndex(imageLoader,0);

or you could define the depth when you add the child:

addChildAt(imageLoader,0);

To resize, try to doing all actions to the picture only after it has loaded (Event.INIT) Use it on the contentLoaderInfo property of your loader.
The full code:

var imageLoader:Loader = new Loader();
imageLoader.load(new URLRequest("http://www.blueidea.com/articleimg/2006/08/3904/images/image-2.jpg"));
imageLoader.contentLoaderInfo.addEventListener(Event.INIT, loadComplete)

function loadComplete(event:Event):void {
	addChildAt(imageLoader, 0);
	imageLoader.width=500
	imageLoader.height=260
	imageLoader.x=imageLoader.y=0
}

Good luck!

Response to: Flash game at full FPS still choppy Posted July 20th, 2010 in Game Development

Is it choppy in both flash debugger and standalone player?

Response to: The Flash 'Reg' Lounge Posted July 19th, 2010 in Game Development

At 7/19/10 04:13 PM, citricsquid wrote: a q for you guys, if HTML5 (canvas + javascript) is ever in a state where it can create things equal to Flash and it's just as easy, will you make the switch? The main disadvantage will be that your source code would be fully available in the page source, would that put you off switching or will you switch regardless?

this all assumes HTML5 becomes as powerful...

I will surely learn it later, but as stated bazillion times before, you can't make cartoons and games in HTML5 (its only good for RIAs)

Response to: 2 quick questions Posted July 19th, 2010 in Game Development

Well, say you have a Player movieclip, and another movieclip called Destination. You have a framelooping function that makes Player get closer to Destination's coordinates every frame. Then you create a mouse listener that changes the Destination's coordinates to your mouse coordinates every time you click on stage.

Response to: 2 quick questions Posted July 19th, 2010 in Game Development

At 7/19/10 08:55 AM, dbigboy wrote: Hello it's dbigboy here asking two questions, the first one is how can i make the player move when i click the mouse?
the second is, how do i submit how i want the player to look, and then play with him?
i need an answer and explanations so on the future i could do it myself.

1) Use code to create a movieclip that your character will move to all the time. When user clicks anywhere on the screen, the movieclip will change its coordinates to where the user clicked, making the player go to that destination.

2) For this you will need to create a few variables (or maybe an Array) which you can edit at the beginning, and later it will just tell the character's movieclip parts to go to certain frames (according to the variables).

Response to: Huge Actionscript 3 n00b needs help Posted July 19th, 2010 in Game Development

I'd say an AS3 book would be the best option, that's how I started. Reading tutorials also helps. I'm writing a blog on programming in Actionscript 3, that might help you. Here are some introduction tutorials: part 1, part 2, part 3.

Good luck :)

Response to: The Flash 'Reg' Lounge Posted July 18th, 2010 in Game Development

I played UT99 recently, its amazing, brings lots of memories...

But the new UTs are still better, the graphics are amazing, as well as the new features. The gameplay is great as always, the only bad thing I can say about the new games in the series is that there are no more Assault maps, used to play those alot in UT99 :(

Response to: as3 depths are killing me... Posted July 18th, 2010 in Game Development

Depths are always troublesome... Have you tried using swapChildrenAt()? You could swap the depths of your player and an obstacle if his y is higher and vice versa...

Here's Mike's post about depths in AS3, really helpful.

Response to: How To Create A Boss(not Answered) Posted July 18th, 2010 in Game Development

At 7/18/10 12:05 AM, game155 wrote: NOOOOOOOOO
DAMN CANT U GUYS LISTEN, U LEARN FROM OTHER PPLE TELLING U HOW..... SHEESH, HOW CAN I LEARN THE ANSWER IF I DUNT KNOW IT.

Shut the fuck up and go read a book on programming.

Response to: Regex sitelock = good? Posted July 9th, 2010 in Game Development

Shit, I forgot about the dots, here's the fixed regex:

/^(http:\/\/)?(www\.)?newgrounds\.com/
Regex sitelock = good? Posted July 9th, 2010 in Game Development

I was wondering how do I site lock a flash (AS3). I decided to use regular expressions, here's what I got:

var url:String=stage.loaderInfo.url;
var goodPattern:RegExp=/^(http:\/\/)?(www.)?newgrounds.com/;
if (goodPattern.test(url)==true) {
	trace("This flash is hosted on newgrounds");
} else {
	trace("This flash is not hosted on newgrounds");
}

Is this a good/effective way of site locking? Are there any flaws? I'd like to know because I've never site locked a flash before.

Response to: How to make a text-adventure game Posted July 9th, 2010 in Game Development

Regular expressions will help you here, google that

Response to: Grain Filter Effect? Posted June 26th, 2010 in Game Development

It's a picture with a transparent texture on top.

Response to: AS3 - Suitable array for heirarchy Posted June 26th, 2010 in Game Development

You can use Vectors, but I don't see why you should.

You can put an Array inside another Array:

var subOne:Array = new Array("one", "two", "three");
var subTwo:Array = new Array("four", "five", "six");
var main:Array = new Array(subOne, subTwo);

That will create an Array that holds 2 Sub-Arrays, which hold 3 Strings each.

Response to: Facebook games Posted June 20th, 2010 in General

About Facebook in general, I have an account but I never use it. Mostly because there is a separate social network site in our country, where all my friends go to.

There really is no point for me going to Facebook, because I only add people that I actually know in real life to my contact list.

Sorry for double post.
Response to: Facebook games Posted June 20th, 2010 in General

I don't play facebook games, because I know they're pointless and there are better games I can play.

But people that make those games actually earn lots of money, because they are aiming for the masses, and most of those that play facebook games probably don't even know any other games.

Response to: LeroyJ has a virus Posted June 20th, 2010 in General

There are less viruses for Macs because they're shit and most people use Windows.

Try System restore...

Response to: EA busted? Posted June 20th, 2010 in General

I tried, works just fine...

Response to: Man killed for watching World Cup Posted June 19th, 2010 in General

I hate all those religious TV shows, they only bring problems.