Sign in to follow this  
e1337idiot

RPG Programming in AS 3.0

Recommended Posts

Hi all, I'm looking for a good tutorial in RPG programming in Action Script 3.0, specifically making a sprite based character move. I've found many for AS 2.0, but none for sprite based characters in 3.0. I hope someone can point me in the right direction, all help is greatly appreciated. --Teh e1337idiot

Share this post


Link to post
Share on other sites
You can simply make a keydown event listener, lets say, the arrow keys.

When the arrow keys are pressed, change the (x,y) of the image depending on which key was pressed.

Aiea

Share this post


Link to post
Share on other sites
Thanks for your reply, but I've come to find out it isn't as simple as that. For anyone wondering this is the code needed to make a sprite based character almost walk:

var speed:Number =5;
var KeyDown:Number = 0;
var moving:Boolean;


addEventListener(Event.ENTER_FRAME,EnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN,KeyPressed);
stage.addEventListener (KeyboardEvent.KEY_UP, stopMoving);

function stopMoving(event:KeyboardEvent):void
{
moving = false
}

function KeyPressed(event:KeyboardEvent) {
KeyDown = event.keyCode;
movingCheck();
}

function movingCheck():void
{
moving = true;
}

function EnterFrame(event:Event) {
if (KeyDown == 38 && moving == true) {
player_mc.y-=speed;
player_mc.gotoAndStop(2);
}
if (KeyDown == 40 && moving == true) {
player_mc.y+=speed;
player_mc.gotoAndStop(1);
}
if (KeyDown == 39 && moving == true) {
player_mc.x+=speed;
player_mc.gotoAndStop(4);
}
if (KeyDown == 37 && moving == true) {
player_mc.x-=speed;
player_mc.gotoAndStop(3);
}
}

The only problem is that I can't get individual walking animations in the form of movie clips within the main movie clip to play. I'm working on it and I've got several other sites I'm using to get the last piece of the puzzle.


What I'd really like now are some AS 3.0 RPG game development resources... unfortunately this site has pretty much no AS 3.0 stuff at all. So if any one knows of any please do share.

Share this post


Link to post
Share on other sites
Ive tried to move to AS3 when doing things like websites, but the overly programmatic coding model just hinders how quickly you get things DONE.

And i've found things like where I put my onClipEvent() etc events and how to properly link them to instances to be unintuitive or just not explained very well.

I like AS2 :D

Share this post


Link to post
Share on other sites
Yeah at this point I like 2.0 much better. I miss being able to attach code to movie clips and dynamic text boxes. :( It just made sense. I'm hoping I'll learn to like 3.0, but with the lack of tutorials in 3.0 coding, and the wealth of tutorials done for 2.0 it's hard not to just say, "Screw it, I'm going back."

This is getting off topic though... No one knows of any game programming in 3.0 tutorial sites? This is sad. At this point it looks like I'm gonna have to make a thread on actionscript.org for every problem I run in to.

Share this post


Link to post
Share on other sites
I liked the idea of the AS3 single event system etc etc, but in practice I could not fully figure out WHERE to put my code! 1st frame? in some .as file? Where?!

There just wasnt much on HOW to go from AS2 coding style to AS3 coding, as in, exactly the best place to put ur original event code etc.

There were the differences but not how to use them. Maybe I didnt look hard enough...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this