Game Character Perspective
I've been working a little bit lately on some actionscript code to adjust a movie clips size bsed on whether he is at the front of the landscape or the back. I'm having some trouble because I want to be able to define the highest and lowest peaks of the resizing but can't seem to get everything to work so smoothly. Heres the AS.
Code: onClipEvent(enterFrame){ if(Key.isDown(Key.DOWN)){ this.play(); this._y += 5; } else if(Key.isDown(Key.UP)){ this.play(); this._y -= 5; } else{ this.stop(); } if(Key.isDown(Key.RIGHT)){ this.play(); this._x += 5; } else if(Key.isDown(Key.LEFT)){ this.play(); this._x -= 5; } }
onClipEvent(enterFrame){ stageheight = Stage.height; stagewidth = Stage.width;
movingspaceheight = _root.movablespace._height; movingspacewidth = _root.movablepace._width; movingspace_y_top = (_root.movablespace._y) - (movingspaceheight / 2); movingspace_y = _root.movablespace._y; movingspace_y_bottom = (_root.movablespace._y) + (movingspaceheight / 2);
diffstagespace = stageheight - movingspaceheight);
minballsize = 60; maxballsize = 100;
ballheight = _root.ball._height; ballwidth = _root.ball._width; ball_y_top = (_root.ball._y) - (ballheight / 2); ball_y_center = _root.ball._y; ball_y_bottom = (_root.ball._y) + (ballheight / 2);
minmaxdiff = maxballsize - minballsize; divisor = movingspaceheight / minmaxdiff; yboundary_bottom = stageheight - (ballheight / 2) yboundary_top = ballheight / 2;
if(ball_y_center < movingspace_y_top){ scale = minballsize; } else if (ball_y_center > movingspace_y_bottom){ scale = maxballsize; } else{ scale = ((_root.ball._y + diffstagespace) / divisor) + minballsize; }
_root.ball._xscale = scale; _root.ball._yscale = scale;
_root.xtext = _root.ball._xscale; _root.ytext = movingspace_y_bottom; } Anyone got any ideas, on how to get this working right. And so I can very easily change the size of the movable space and everything will remain to work the same.
FlashKit > Flash Help > Flash ActionScript
Posted on: 07-30-2005, 01:31 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Making A Game: Got Speed Issues - Requires An Advanced Perspective...
alright, im working on an action game here that uses a lotta flashy graphics. Not so much intense trawn stuff, real simple art at the moment, but it uses a lot of clips on screen at once. Now it tends to rund fine for a while on my 1.5ghz g4 and even better on the 2.4ghz P4's at school but even still when all enemys are on screen as well as all the bullets and so forth it starts to chug even on such beasts. Now, im sure as hell people have made more complex **** than this and got the required specs down, and im sure this code could run a lot smoother but i need an experienced opinion on this. I have a feeling its coz all the functions are pretty much checking everything all the time, even when all the clips are deleted its still slower than when i opened the swf. The script was written in flash MX but all the code is all flash 5 functions.
All the code is in one frame on the actions layer, and all functions are activated in the actions mc located in the top left corner. Not ever thing is commented on but if you know your code you should be able to work it out. I have to addmit it will no doubt look confusing first, of course i know it like the back of my hand coz i wrote it.
I hope to push this into a full on game coz ive got heaps of ideas for enemys and game play that follow the same formula ive already developed so help with this speed issue would be much appreciated coz its what holds it back to being truely playable.
Thanks in advance to anyone that can help!
alright, heres the keys for game play:
arrows=movement
space=shoot in moveing direction
shift=hold while shooting to lock last direction
a,s,d,w=shoot directional target ball
when the target ball hits somthing a reticle will appear around the enemy and the turret gun will fire away at it till it blows the armor off or you lock on somthing else
only the red guys die, big smile guy has no hitest yet
enjoy ^_^
[F8] Help With Character Movment In Game
Ok the title didnt make THAT much sence but basically i have my game set up with 4 png graphics, and 5 movie clips for the hero.
theres a png of him facing left, right, up, and down.
theres 4 different movie clips one walking left, right, up and down
and then the actual hero movie clip wich has the first 4 frames as each png and then 8 more frames 2 for each direction.
on the hero movie clip i have this.
Code:
onClipEvent(enterFrame){
if(Key.isDown(Key.LEFT)){
this.gotoAndPlay('walkingl');
this._x -= 5;
}else if(Key.isDown(Key.RIGHT)){
this.gotoAndPlay('walkingr');
this._x += 5;
}else if(Key.isDown(Key.UP)){
this.gotoAndPlay('walkingu');
this._y -= 5;
}else if(Key.isDown(Key.DOWN)){
this.gotoAndPlay('walkingd');
this._y += 5;
}
}
and then in the actual movie clip lets say you press down it looks for walkingd wich is 2 frames it plays the first gets to the second and the second one is this
Code:
gotoAndPlay('walkingd');
if(Key.isDown(Key.DOWN)){
}else{
_root.hero.gotoAndStop('no_walkd');
}
this makes it so it goes back and plays the the frame before it instead of going to the next frame and changes the graphic to a no walk graphic if down is no longer pressed
this works fine BUT i have 6 direction movment wich is weird but it has to do with the order of the hero movie clip since in the clip i have...
no walkd, no walkl, no walkr, no walku, walkd, walkl, walkr, walk up
as the frame sequence what happens is if you hold down... while holding down you can still move left right and up
if your holding left you can only move right and up and if your holding right you can only go up and when you are holiding up its correct.
I only want 4 directional movment so if left is held you only walk left ect.
i attached the fla.
rpg.fla is for flash 8 users, rpgmx2004.fla is for mx 2004 users.
all help appreciated thanks.
[F8] Help With Character Movement In Game
I am trying to make a game in flash 8 but i got somewhat stuck now. The thing is the character is a movie clip with various animations inside of walking, atacking, jumping, etc...
So i am using the following code:
Code:
onClipEvent (load)
{
speed = 10;
}
onClipEvent (enterFrame)
{
if (Key.isDown(Key.SPACE))
{
this.gotoAndStop(2);
}
if (Key.isDown(39))
{
this.gotoAndStop(3);
_xscale = +100;
this._x = this._x + speed;
} // end if
if (Key.isDown(37))
{ _xscale = -100;
this.gotoAndStop(3);
this._x = this._x - speed;
} // end if
if (Key.isDown(Key.CONTROL))
{
this.gotoAndStop(4);
} // end if
if (Key.isDown(Key.SHIFT))
{
this.gotoAndStop(5);
} // end if
onClipEvent (enterFrame)
{
if (Key.isDown(Key.SPACE) && !jumping)
{
vel_y = 36;
jumping = true;
} // end if
if (jumping == true)
{
vel_y = vel_y - 2;
if (vel_y <= -15)
{
vel_y = -15;
} // end if
this._y = this._y - vel_y;
} // end if
if (_root.ground.hitTest(this._x, this._y + 35, true))
{
vel_y = 0;
jumping = false;
} // end if
}
onClipEvent (enterFrame)
{
this._y = this._y + 16;
if (_root.ground.hitTest(this._x, this._y + 1, true))
{
this._y = this._y - 16;
} // end if
}
onClipEvent(enterFrame) {
//change dimensions for document width
if(this._x >= 750) {
_root.ken._x = 750;
}
if(this._x <= 10) {
_root.ken._x = 15;
}
}
Ok everything works perfectly except when i jump diagonally cause as i do that i am pressing both walk and jump button and the animation gets stuck on the first frame of the walk animation. What i want to happen is that as soon as i press space (jump) the jump animation will play the hole way through untill it finishes, even if i press any other button.
Another minor problem that is not very important is the walk animation. I want the walk animation to imediatly stop as soon as i let go of the directional buttons.
i tried using:
onClipEvent(keyUp) {
_root.character.gotoAndStop(1);
walkSpeed = 10;
But that cut all my animations as soon as i released any button, when i just want it to happen when i released the left or right button.
Any help will be greatly apreciated.
Game Character Jump
I'm using the following to make a game character move about the stage:
var dude:Object = new Object();
dude.onKeyDown = function() {
switch (Key.getCode()) {
case Key.UP :
checkY();
checkDudeScaleSm();
_root.dude_mc._y -= 5;
_root.dude_mc._yscale -= 2;
_root.dude_mc._xscale -= 2;
_global.currentXScale = _root.dude_mc._xscale;
_global.currentYScale = _root.dude_mc._yscale;
break;
case Key.DOWN :
checkY();
checkDudeScaleLg();
_root.dude_mc._y += 5;
_root.dude_mc._yscale += 2;
_root.dude_mc._xscale += 2;
_global.currentXScale = _root.dude_mc._xscale;
_global.currentYScale = _root.dude_mc._yscale;
break;
case Key.RIGHT :
checkX();
_root.dude_mc._x += 5;
break;
case Key.LEFT :
checkX();
_root.dude_mc._x -= 5;
break;
case Key.SPACE :
/*
HELLPPP!!!
*/
break;
}
};
Key.addListener(dude);
In the case Key.SPACE, I'd like to use the spacebar to make the character 'jump' over obstacles. How would I do that?
Thanks in advance.
sleepydad
Game Character Customization
Hi,
Just wondering if any of you have come across a good tutorial regarding character customization for a flash game. What I mean by character customization is the ability to change the articles of clothing that an avatar is wearing. The part that of course becomes complicated is when the avatar is not stationary but when he is in motion (walking, dancing). How might you attach many different articles of clothing without actually having to change the animation. Let me know.
icekube12jr
Game Character Issue
my main issue is that when the character gets down y still cant fix it so that it faces the right direction......my most succesful achievement was to let him facing the right direction but if you pressed DOWN button again it changes left to right right to left etc.....
I was using....
If(key.isDown(Key.DOWN)
if(_currentframe !=5)
gotoandplay(5)
)else if (key.isDown(Key.DOWN)
if(_currentframe !=6)
gotoandplay(6)
this is the best one with the one I achieved highger.....any idea?
2d Game( Directing The Character With Keys)
I've already visited the Games tutorials in Flashkit yet so far they cover games that can make the character move in all directions, but I want to make the character move LEFT with the left key and RIGHT with the right key. I have that down but here is the thing that I have been trying to make it do. I want the Character's running animation to halt(the animation is a seperate movieclip in the next frame) when the specific key is released. So if he is standing and facing to the left and I tap the right key quickly, he'll turn to the right but won't run unless that key is held down. If the key that is being held is released the character discontinues its running and goes to the frame with him facing that same direction.
Confusing? If you need more details on how the layout is I'll be glad to answer if it helps me obtain this goal. Thanks
Game Character Movement Code
I am trying to make an action style game. I have the main character set up as an MC with other MCs inside it on the different frames. These are the graphics for crouching, walking right, etc. So frame 5 of the main MC is the graphic for walking right.
I have coded it so when right is pressed then the MC jumps to frame 5, but when i add in the code for walking left, nothing happens.
The current set up is 4 dynamic text boxes that display 0 or 1 depending on whether UP, DOWN, LEFT or RIGHT are pressed. The main MC then looks at these and then plays the appropriate frame. I don't know why I didn't just use straight forward
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop(5);
}
I have the FLA file ready to send via email cos its too big to fit on the forum. Please say so here or email me if you would like it. The fla has little explanations all over it to make it clearer.
I'm in flash 5 so if you do anything in MX please convert it to flash 5 format.
============
TiMo
Platform Game: Character 'shaking'
I can't really figure out this one. I'm making a platform tile-by-tile based game in Flash MX with Actionscript. Anyway, the FLA is attached, and I don't mind giving out my code, some of it (the map drawing) is from tutorials, some (top/bottom collision detection, graphics etc.) is my own, but anyway...
I have an issue with it. You start on on the raised tile. If you jump up, and hit the tile straight above you, and then as you are falling, land on the 4 tile raised platform 2 tiles to the right, the character will start 'shaking' (and won't be able to jump). Basically his y position keeps changing by one back and forth. Something really weird with my yVelocity, because it sets to 0 every time he lands on solid ground. I've also triggered it a couple of other ways. I'm wondering if there's some kind of fundamental problem in my code that's causing this, because I'm pretty sure it's math-related (maybe the fact I haven't rounded numbers?) I used the high values I did for velocity so I could use decimal points, so to speak, and not have the character end up being drawn in between pixels. Oh, yeah, I know there's no horizontal colision detection yet but that's coming. :P
I know it's a lot to ask, but maybe some of you gurus can find the problem without too much work.
Thanks,
Keith
[F8] Flash Game Character AS Problem
Hi ppl.
Im trying to develop a flash platform game. I have set up my character's animations. (incase it matters I created a MC then created each animation as a seperate MC on each frame within the main MC)
I have began the actionscripting of the character and so far he can begin with the idle animation, then walk left and right, but when you release the arrow keys he continues to walk on the spot. No matter how hard I try I cannot correct this problem. Can anybody help plz?
Here is the character's AS as far as I could do it correctly:
Code:
onClipEvent (load) {
xscale = _xscale;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
_root.player_mc._x = (this._x-3);
_xscale = -xscale;
tellTarget (_root.player_mc) {
gotoAndStop(2);
}
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_root.player_mc._x = (this._x+3);
_xscale = xscale;
tellTarget (_root.player_mc) {
gotoAndStop(2);
}
}
}
[MX] Building Character For Non-game Animation
I wouldn't consider myself terribly new at flash, but this is one thing that stumps me, bad.
How do I properly build an animated character? What I have right now is a little complex in the sense that it has arm and leg joints, torso pivot point, various hand positions, eyes, mouths, etc. I keep hearing about nested symbols, but I don't think I'm doing it right because sometimes they don't work when I test the swf. Some do, others with identical construction do not. When I take them out into another fla, the parts work on their own, but I don't really know what that means. I was under the impression that you'd nest movie clips(or graphics?) within movie clips, the outermost clip could then be manipulated while the inner clip would just go through its animation cycle unaffected, making it easier to animate things like arms and legs, etc.
Is there a thing as too much nesting? (character>left arm>lower arm>forearm & hand) Do I have to use action scripting? Should graphics be used inside the movie clips or should everything be movie clips?
Using Sprites For Character Game/animation
Hi there,
I am planning to add some creativity to my site by adding a game-like flash program.
It involves a character walking left to right and beign able to jump horizontally up. I have the sprites here:
http://yolkfolk.com/site/images/misc...C64CKDizzy.PNG
But I am not too sure how I would implement these into Flash to make the charcter move and animate at the same time.. For example when he walks right, his arms will go across his sides, as seen in the above sprites.
Any ideas on how this would be done?
Problem With Controlling Character For A Game...
Hi, I'm having a bit of trouble with the game I'm designing. In the game, you control a character, and you're capable of traveling in any of 8 directions. These directions are 1,2,3,4,6,7,8, and 9 on the Num pad, and that should be pretty self-explanitory as to what directions for what button etc. Anyhow, I'm relatively new to game dev but this idea just came to me and I'm eager to try it out. Anyhow, what would be necessary for controlling the character? Right now I have 8 mc's, labled walk_up, walk_upright, walk_upleft, etc. I have used hittest before so that won't be a problem, I just don't know how to give the user control of the mc and actually move the character to their will. I really have no clue where to start so anyhow help is really appreciated. Thanks!
Marc
*edit* I should also add that there are different animations for each direction (walk animation). Keep that in mind. Thanks again.
I Need To Know Act. Scr. With A Character Select With My Fighting Game
I have the picture of the character select already done , and the p1 bar for the character select , but I don't know how to put action scripts on how to make the bar move to a character and to make the character show on screen and playable in next key frames . If I can , can I send the actual Macromedia Flash MX 2004 file , so that yall can tell me the correct actions , and I can understand more ?
Game Help: Custom Character Color MC
Hello, I am making a custom character menu. I have a color code that works and all my buttons work. The buttons work by going to an MC that has "hairoptions" and selecting a frame(with the wanted hair..for example: short). But my problem is that I want my ColorPicker to always apply color to the object you just selected. So I donīt have to make a Color-Picker to each and every option ...
So my question is: How to select an MC and have the color picker only be applied to that MC, and when I select another one, the color picker would only be applied to that MC and so on ...?
Can anyone help?
Code:
This is my button code:
hairshortb.onPress = function () {
optionsmenu.gotoAndStop("hairshortb");
}
This is my color code:
Code:
function red() {
var my_color:Color = new Color(what to write here?);
var myTransform:Object = my_color.getTransform();
myTransform = { ra: 228, ga: 73, ba: 35};
my_color.setTransform(myTransform);
}
Game Character Movement Question.
I'm making a game with a top down view like in The Legend of Zelda for SNES (not directly top down but at an angle). I want my character 'hero' to go to the walk cycle for the appropriate direction nested in the hero timeline when the arrow keys are pressed. Then, when that key is released I want him to stay facing that direction but go to the frame of him standing still. I can successfully do this with the "right" arrow key and but will play the first frame of the correct walk cycle when the other keys are pressed but when the keys are released it jump to the facing right standing still frame. The right key's code comes first so I think it's a compatibility issue with the other keys. Here is my code for the right key and it's the same for the other keys.
onClipEvent (load) {
speed = 5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x = this._x+speed;
gotoAndPlay("WalkRight");
}
if (!Key.isDown(Key.RIGHT)) {
gotoAndStop("StandRight");
}
It makes sense that adding a variable "heroPosition" would work if when the key's are pressed have the variable be that key (ex. if right key is pressed heroPosition = "Right") and then make the second if statement for the key if (heroPosition = "Right" && !Key.isDown... etc. This doesn't work. P.S. First time poster.
Controlling A Character In A Flash Game.
Hi there,
At the moment I've been looking at a tutorial on how to create a space invaders type game, my space ship will move off the swf stage, is there a some actionscript that will stop the spaceship moving off the stage?
Many thanks,
james
Game Actionscript - Character Movement
hi guys i have this AS code and am no sure what i would need to add/change to allow the character to fall from a platform if they're no longer on it... currently the character stays at the same _y position even when its no longer on thew platform
can any1 help me out with the changes i need
heres the code i currently have
Code:
onClipEvent (load) {
y_start = _y;
jumping = false;
jumpspeed = 0;
speed = 5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
this.gotoAndStop("Walking Left");
this._x -= speed;
}
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop("Walking Right");
this._x += speed;
}
if (jumping) {
this.gotoAndStop("Jumping");
_y += jumpspeed;
jumpspeed += 1;
if (_y>=y_start) {
_y = y_start;
jumping = false;
}
} else {
if (Key.isDown(Key.SPACE)) {
jumping = true;
jumpspeed = -10;
}
}
if (_root.Platform.hitTest(this._x, this._y, true)) {
jumping = false;
}
}
Fighting Game:Character Change
HI
i have recently been working on a 2 player fighting game
but have encountered a problem. I want to make it so that there are two characters to choose from but i dont know how to do that without making the fight over and over again with all the different outcomes for example i would have to make it so there is a fight were player 1=character 2 and player 2=character 1 then iwould have to do
player 1=character 1 and player 2=character 2 etc..
so is there a way i can switch what characters are fighting based on what they chose at the menu?
P.S. i use flash 8
THANKS HEAPS
Drew
[help] + Flash Game + 2 Character Jumping
I am busy with a flash game at the moment, I have finished everything EXCEPT for the character movement.
I have 2 characters and a seesaw. When the one character jumps down onto the seesaw then the other one flies up. If you don't understand then take a look at this game...
http://www.cartoonnetwork.com/games...ight/index.html
That is exactly what I'm trying to achieve (only the jumping), but I can't seem to get it right.
I have tried to make a MC of the movement and then have it so that when the user pushes SPACE on the keyboard everything moves like it should, but this doesn't work because it doesn't run smoothly or all in one shot.
Does anyone have ANY idea of how I can achieve it?
I am about to pull my hair out!! I am desperate for help. I would really appreciate it if someone would help me. please!
Moving Character In Game In 8 Directions With Keyboard.
I have 8 MC's, each of a man walking in a different direction. They are called:
Up
Down
Left
Right
TopLeft
TopRight
BottomLeft
BottomRight.
All of them will be on the stage with no alpha, exept up, which would have full alpha, and when you press the up key all of them move upwards, i put this on the up mc:
Code:
(enterFrame) {
if (key.isdown(key.up)) {
_y -=3;
_alpha = 100;
}
}
And on the other mcs i put this:
Code:
onClipEvent (enterFrame) {
if (key.isdown(key.up)) {
_y -=3;
_alpha = 0;
}
}
But when I came to the angles this script never worked:
Code:
onClipEvent (enterFrame) {
if (key.isdown(key.up)) && (key.isdown(key.right)) {
_y -=3 && _x += 3;
_alpha = 100;
}
}
Because the up and right key were still being pressed it go confused with the alpha?
Got n e ideas of wot i can do? So I can get the same result?
Making A Game Character Jump Realistic?
Does anyone know how to make a character jump realistic? I tried for 2 days to look for an answer but everything I tried failed.
There shoud be a sort of Math.sin ecuasion in the code but so far I'm lost.
I'd planned to make the character jump by pressing the UParrow.
Can anyone help me?
Thx. Jurriaan Hos
Game Style Website; Character Left And Right
Hi guys,
I really need some help with a code for a website I am developing - i thought i could avoid the issue but it has made it way too complicated and im sure someone will know the answer on here!
Basically, i have my stage and i have a long background image that only a small percentage is visable in the stage area at any one time. I have a character who i want to walk left and right and when the character gets infront of certain things on this background image i would like to hit enter or up and for a movie clip to play overlaying the background image, which will load the text for that link. Does anyone have anyidea the actionscripting i would need for this? The character barely needs to move - the background is what should scroll left and right when the keys are pressed....
I would REALLY appreciate any help at all.
Thankyou!
How To Create AI Or A Character To Respond To The Player In The Game.. Pls Help Me
Hi,
Trying to find out how to create this part for a game. I am trying to create a game, which will have similarity to an RPG game. I need to check how i can let the character perform the task of response when the main character go and speak to it. This is what i hope to achieve, when the main character go towards a stationary character, when it press the enter key, the stationary character would response to the main character. e.g the stationary character will have a text box saying "hi, how can i help you" and when the player press enter, it will appear "1. information 2. help 3.end chat". than when the player press the designated key e.g '1', the stationary character will response to what it has been stored.
Really need help on creating this part. really apprieciate the help.
Thank you
[F8] Printing A Dynamic Dress Up Game Character
Hi
I have a dress up game Ive built using drag and drop clothes and my client want s to be able to print the character after these clothes are applied. Any idea how I can tell the print button to recognize which clothes are on my character and then to print it? Im porobably goign to need to set up the character to appear with the combo of clothes on a specific print page as well...
really appreciate the help...including all the help in the past you guys rock!
straitjackettuxedo
Making A Game- Don't Want To Have The Character Walk Through Buildings
I am in the middle of making a game, and I have a character who is controlled by the arrow keys. I don't want him walking through the trees and buildings, and other stuff and I don't know how to do this. I thought it might have to use hitTest, but I have been having troubles with it. Any ideas? (I'm a bit of a newbie to actionscript )
How Do I Make A Character Select Menu For My Game?
I am fairly new to flash and I need a character select menu. This is how it will work... The player will be able to pick out the style of his character's hair and the color of the hair, and the same with the body and shoes. I found a game that has the same kind of menu I want, the game is called Thing Thing 3 (on newgrounds.com). I can make the select menu just fine, but I need the ActionScript to allow them to keep the changes to their character in the game.
My game is a shoot 'em up <<- Didn't know if that would help any...
The One And Only,
Bandit
PS. Feel free to ask if u have anymore questions.
Detecting Key Inputs From Keyboards For Character In Game
well i am working on a second controllable character for a game and i am using the arrow keys for one character so i want to use W, A, S, D for the second character. i think i have to use ascii but i am not sure if i am correct this is what i got so far
first character
this one works
PHP Code:
onClipEvent (load)
{
//dircetional function and scalar
Character_Move_F = function()
{
if (Key.isDown(Key.RIGHT))
{
this._x = this._x+14;
_root.Simme_MC._xscale=+100
gotoAndStop(2);
}
if (Key.isDown(Key.LEFT))
{
_root.Simme_MC._xscale=-100
this._x = this._x-14
gotoAndStop(2);
}
// up and down directional
if (Key.isDown(Key.UP))
{
this._y = this._y-=5;
gotoAndStop(2);
}
if (Key.isDown(Key.DOWN))
{
this._y = this._y+=5;
gotoAndStop(2);
}
// Pimp Slap attack
if (Key.isDown(Key.SPACE))
{
gotoAndStop(4);
//stop();
}
wid = _width/2;
hght = _height/2;
}
}
second character
this one is not working
PHP Code:
onClipEvent (load)
{
//dircetional function and scalar
Character_Move_H = function()
{
if (Key.isDown(Key.BACKSPACE)) using backspace as a test
{
trace("backspace");
this._x = this._x+14;
_root.Hooker_MC._xscale=-100
gotoAndStop(2);
}
if (Key.isDown(Key.getAscii(65)))
{
_root.Hooker_MC._xscale=+100
this._x = this._x-14
gotoAndStop(2);
}
// up and down directional
if (Key.isDown(Key.getAscii(87)))
{
this._y = this._y-=5;
gotoAndStop(2);
}
if (Key.isDown(Key.getAscii(83)))
{
this._y = this._y+=5;
gotoAndStop(2);
}
wid = _width/2;
hght = _height/2;
}
}
Game Character Movement Action Script
I have a character in a movieclip with contains movieclips on the timeline which I've applied behavior to but I have problems when I try to use any of the letter characters to apply a key press comand. Could some one please check out the attached file and see if they can offer a solution. Also can someone please provide an answer to the problem of a character returning to it's orginal position. rather than staying in the last position used.
The file can be found here -
Problem File
Platform Game - Screen Scrolls With Character
Hey,
I'm making a platform game using AS3, my character moves from left to right when the arrow keys are pressed, he moves across the screen - I want the screen to scroll with him so that I can make long levels.
Whats the best way to go about doing this? I've thought about creating all the elements apart from the character in a separate movieclip - while the arrow key is pressed the background mc moves, not the character mc.
Would this be a good approach?
Thanks
Ryan
Platform Game - Screen Scrolls With Character
Hey,
I'm making a platform game using AS3, my character moves from left to right when the arrow keys are pressed, he moves across the screen - I want the screen to scroll with him so that I can make long levels.
Whats the best way to go about doing this? I've thought about creating all the elements apart from the character in a separate movieclip - while the arrow key is pressed the background mc moves, not the character mc.
Would this be a good approach?
Thanks
Ryan
Game - Character Movement Problems [renamed]
Hello.
I thought i would have a go at making a platform game in Flash MX 2004.
However i can't get my charecter move
I have tried so much, however, i'm just stupid!
I am trying to script my movie clip so that:
When the key 'E' is pressed the charecter moves right.
When the key 'Q' is pressed the charecter moves left.
When the key 'W' is pressed the charecter jumps.
When the key 'S' is pressed the charecter crouches (either changses to crouching movie clip or squashes current movie script if this is possible.).
When the key 'D' is pressed the charecter moves right while crouched.
When the key 'A' is pressed the charecter moves left while crouched.
I have a charecter that is a movie clip. This is what i want to move.
When the charecter jumps or is in the air i want my charecter to fall down until it reaches a movie clip with the instance name of 'platform'
When the charecter crouches i either want it to change movieclip or sqaush the current movie clip.
The charecter must alwaysbe touching a platform unless if it is jumping
Please can someone help me?
My File
This is what i have. I have removed the actionscript that i had because it didn't work Please can someone tell me what i should put, or even better alter the file for me
Thank You
Platform Game - Screen Scrolls With Character
Hey,
I'm making a platform game using AS3, my character moves from left to right when the arrow keys are pressed, he moves across the screen - I want the screen to scroll with him so that I can make long levels.
Whats the best way to go about doing this? I've thought about creating all the elements apart from the character in a separate movieclip - while the arrow key is pressed the background mc moves, not the character mc.
Would this be a good approach?
Thanks
Ryan
Game Character X Axis Walk Problem.
Last edited by OptikaL : 2003-11-04 at 16:02.
In this game I am trying to code, I have the character do punches, kicks, and jumps. My goal is to have the character use the smae punch/kick/jump button, regardless of what way he is facing(left or right)
in my main scene I have coleMain_mc, and inside it contains coleRight_mc & coleLeft_mc(on frame 1 and 2 respectivly). those two movie clips contain the code of the punch/kick/jump buttons. That all works fine. my problem is when the user walks right for a bit then when the user pushes to go left he starts over at the original start position.
the problem is because my code is:
ActionScript Code:
// cole walk right
if (key.isDown(Key.RIGHT)) {
_parent.gotoAndStop(2);
}
// cole walk left
if (key.isDown(Key.LEFT)) {
gotoAndStop(2);
_x -= 5;
}
I need to code it so that the character turns left and right according to his position on the screen, and not start over at the start point.
Hopefully someone can help me figure this out. If you need more info about what I am doing let me know
thanks in advance.
EDIT: forgot to include the game:
http://www.diodedesigns.net/showcase...442/test3.html
Fighting Game...why Does My Character Stops Moving After Running?
ok...in my fighting game....
-I made a movie clip named "Player1".
-I made a button in the first frame of the clip.
-I called the first frame "standing"
-The second frame is when running...
-This is the action of the button
on (keyPress "<Left>") {
gotoAndStop (2);
}
in this frame (2), I got another button with a movie clip inside (when the character is running.)
This is the action of the button on frame #2
onClipEvent (enterFrame) {
if (key.isdown(key.LEFT)) {
_x-=15;
}
}
onClipEvent (enterFrame) {
if (!key.isdown(key.LEFT)) {
gotoAndStop ("standing");
}
}
When I run the game, the character runs when I press the LEFT key but when he stops running, all the keyboard keys don't work if I repress on it...what's the problem????
Please reply!!
-=FL/SHMAN=-
Hello Game Help Please, I Need A Hittest Code For Objects For Character To Walk On
Thank god for this newbie forum, I was using another site that didn't have one, and didn't get much help.
I'm making a platform game ( not with tiles) and I want to make objects that the character can't walk through. Like stairs, that it can walk up and down. Or a block to jump on.
I need simple actionscript code for an object, so the character doesn't walk through it and can walk on top of it. Please please help!
Also a way so if they stop in front of another character, and press 'g' or something, it goes to a frame where the character is talking. But I mainly need the objects thing.
(It's a side view game like the old mario ones)
If anyone knows how to make it side scrolling too?
This is the actionscript for the character( I used a open source fla from this site to make it, and I changed all the images to a different character) The code works, but I want to add some code to it to make it stop when it hits an object, and be able to walk on the object. Or code to add to the object itself.
onClipEvent (load) {
move = 0;
lock = true;
}
onClipEvent (keyDown) {
this.mario.play();
}
onClipEvent (keyUp) {
this.mario.gotoAndStop(1);
}
onClipEvent (enterFrame) {
if (move == 0) {
if (lock) {
this._x += Xstep;
Ystep = 0;
Xstep = 0;
if (Key.isDown(Key.LEFT)) {
Xstep = -10;
Ystep = 0;
this.gotoAndStop("left");
} else if (Key.isDown(Key.RIGHT)) {
Xstep = 10;
Ystep = 0;
this.gotoAndStop("right");
}
}
}
}
onClipEvent (enterFrame) {
render();
}
onClipEvent (enterFrame) {
for (i in _root) {
if (i.substring(0, 4) == "coin") {
if (this.hitTest(_root[i])) {
_root[i].gotoAndStop(2);
_root.score += 1;
}
}
}
}
onClipEvent (enterFrame) {
for (i in _root) {
if (i.substring(0, 0) == "bad") {
if (this.hitTest(_root[i])) {
_root.lives -= 1;
if (_root.lives == 0) {
_root.gotoAndStop(2);
}
}
}
}
}
onClipEvent (enterFrame) {
for (i in _root) {
if (i.substring(0, 4) == "save") {
if (this.hitTest(_root[i])) {
_root[i].gotoAndStop(2);
_root.score += 10;
}
}
}
}
Eleferonato Platform Game - Character Size - Problem
Hey Guys,
I've got a Problem with the size of my character in this code...
Creation of a platform game 1.5
I've changed it from Width 10, Height 20, to Width 21, Height 56
Therefor I've changed this line of code...
Code:
#Original
hero.upy = Math.round((point_y - 10 - Tile_size/2) / Tile_size);
Code:
#Changed
hero.upy = Math.round((point_y - 27.5 - Tile_size/2) / Tile_size);
Also I've changed the values of the whole upleft and upright...
Code:
if(hero.leftC && hero.upC){
//orginal forecast_x = (hero.leftx+1) * 25 + 5;
forecast_x = (hero.leftx+1) * 25 + 60;
//orginal forecast_y = (hero.upy) * 25+10;
forecast_y = (hero.upy) * 25+36;
hero.y_speed = 0;
}
After this changes the charakter's head is blocked
But when i try to jump the character is moving into the tile...
All the code I've used for this little game is from the link at the top ...
So now I add my SWF file and hope somebody could help me with this problem...
Link to my SWF
Flash Game Help? Multi Key Tapping For Character Movement?
Hello, im creating a racing game in flash where 3 people run along a race track the the finish line. One character will be controlled by the user in which they have to rapidly press 2 button keys as fast as they can to make the racer move. The faster they press the keys, the faster the player will run.
How do i do this? I dont know where to begin, here is an image of my game below, its very basic at the moment.
http://img503.imageshack.us/img503/1...ackraceua5.jpg
Questions About Random Character Movement And Hit Detection For Game [renamed]
Hey every one i was thinking of making a new game where there are rebel smiley men( because i love smileys) and you just kill them and get as high a score as you can.
What i need to know is how i can make them have random movement.
Not just normal random movment but when it decides to walk up it will change to a different frame within the rebel and make it face the direction of its movment.
i also ened to know if when a mc moves into a invisable barrier or the rebels sight that it will try and kill the mc.
Thanks in advance
Flash 8 Racing Game Question Part1: Muti Tapping Keys For Character Movement?
Hello, im creating a racing game in flash where 3 people run along a race track the the finish line. One character will be controlled by the user in which they have to rapidly press 2 button keys as fast as they can to make the racer move. The faster they press the keys, the faster the player will run.
Question: How do i do this? I dont know where to begin, here is an image of my game below, its very basic at the moment.
[MX] Platform Game: Object Character Can Walk On+not Walk Through. Hittest?
I'm making an art-based ( hence me not minding where I get the code) game in Flash MX. (non tile, side view)
I need a bit of actionscript to add to the character/object so it can't walk throught the object, and can walk on it. To be applied to stairs, blocks, etc.
This is the actionscript for the character( I used a open source fla from this site to make it, and I changed all the images to a different character) The code works, but I want to add some code to it to make it stop when it hits an object, and be able to walk on the object. Or code to add to the object itself.
onClipEvent (load) {
move = 0;
lock = true;
}
onClipEvent (keyDown) {
this.mario.play();
}
onClipEvent (keyUp) {
this.mario.gotoAndStop(1);
}
onClipEvent (enterFrame) {
if (move == 0) {
if (lock) {
this._x += Xstep;
Ystep = 0;
Xstep = 0;
if (Key.isDown(Key.LEFT)) {
Xstep = -10;
Ystep = 0;
this.gotoAndStop("left");
} else if (Key.isDown(Key.RIGHT)) {
Xstep = 10;
Ystep = 0;
this.gotoAndStop("right");
}
}
}
}
onClipEvent (enterFrame) {
render();
}
onClipEvent (enterFrame) {
for (i in _root) {
if (i.substring(0, 4) == "coin") {
if (this.hitTest(_root[i])) {
_root[i].gotoAndStop(2);
_root.score += 1;
}
}
}
}
onClipEvent (enterFrame) {
for (i in _root) {
if (i.substring(0, 0) == "bad") {
if (this.hitTest(_root[i])) {
_root.lives -= 1;
if (_root.lives == 0) {
_root.gotoAndStop(2);
}
}
}
}
}
onClipEvent (enterFrame) {
for (i in _root) {
if (i.substring(0, 4) == "save") {
if (this.hitTest(_root[i])) {
_root[i].gotoAndStop(2);
_root.score += 10;
}
}
}
}
Instantiating Character Class Inside Of Game Class
I am having a problem instantiating a Character class inside of a game class.
P.S. I am working on converting http://oos.moxiecode.com/tut_01/index.html these tutorials to A.S. 2.0.
Game:
ActionScript Code:
if ( i == charPos[1] && j == charPos[0] ) {
var char:Character = new Character();
char._x = (j*tileWidth)+tileWidth/2;
char._y = (i*tileHeight)+tileHeight/2;
}
Character:
ActionScript Code:
class classes.Character extends MovieClip {
function Character() {
var h = createEmptyMovieClip("holder", getNextHighestDepth());
var char = h.attachMovieClip("char", "char", getNextHighestDepth());
trace("new character created");
}
}
The & Character In Flash...how To Use URLs That Contain The & Character...
I am loading in an array or urls from my database via php into my flash movie.
the output of my script looks like this:
quote:
--------------------------------------------------------------------------------
&id=1,&imagelist=1.jpg,&urls=http://www.homemade.ch/shop/100/conliste.asp?langext=&katno=8|&titles=Silence|&com ments=Silence, a painting by Bea Fehr|
--------------------------------------------------------------------------------
problem is that the url contains the '&' character, which Flash uses to seperate the variables....
ex:
http://www.homemade.ch/shop/100/con...angext=&katno=8
but problem is that it is being read into flash as this:
http://www.homemade.ch/shop/100/con_liste.asp?langext=
becuase Flash cuts it off when he see the '&' sign.
How can I workaround this problem, has to be a common issue I would guess since lots of URLs have this format....?
Do I need to write some parsing code?
Perspective
How do I tell an object (that I am dragging) to get smaller when it goes up on the y axis and gets larger going down the y axis? For the sake of making dropzones and dropobjects in perspective.
Perspective
hi guys,
i just need some help making a symbol shrink as it gets dragged closer to a horizontal line and then large as it moves away.
Trying to give the image of perspective.
Any help towards this would be great.
Thanks,
dEX
Perspective
I am trying to create a 3d 3 Panel Display with a dead on View so the outer edges of the outer displays are the larger base to the trapazoids. Problem is you can only manipulate MCs with the skew. This causes them to be parallelograms. Has anyone been able to make this effect or been able to create this effect with some sort of work around?
Thanks in Advance,
ESE51
|