Announcement

User registrations are currently disabled due to high spam traffic.

#1 22/04/09 7:45pm

kamac
Member
Registered: 21/04/09
Posts: 13

Walking stick .fla

I need an example of .fla where is stick able to move left right up down and there are walls + he cannot pass these walls. Can someone gimme that .fla example? pleeease

Offline

 

#2 22/04/09 9:35pm

g0ofygoober
Hardcore Member
Registered: 28/10/08
Posts: 194
Website

Re: Walking stick .fla

cant be bothered making a .fla but here's the code paste it on whatever you want to move. also this code is for the default 550 by 400 stage.

onClipEvent (enterFrame) {
    if (Key.isDown(Key.UP) && this._y >0) {
        _y -= 5;
    }
    if (Key.isDown(Key.DOWN) && this._y <400) {
        _y += 5;
    }
    if (Key.isDown(Key.LEFT) && this._x > 0) {
        _x -= 5;
    }
    if (Key.isDown(Key.RIGHT) && this._x < 550) {
        _x += 5;
    }
}

Offline

 

#3 22/04/09 9:38pm

kamac
Member
Registered: 21/04/09
Posts: 13

Re: Walking stick .fla

thx but how to do to player cannot pass the walls?

Offline

 

#4 23/04/09 1:37pm

kamac
Member
Registered: 21/04/09
Posts: 13

Re: Walking stick .fla

any help? Lets say i have made a circle wit this code:

onClipEvent (enterFrame) {
    if (Key.isDown(Key.UP) && this._y >0) {
        _y -= 5;
    }
    if (Key.isDown(Key.DOWN) && this._y <400) {
        _y += 5;
    }
    if (Key.isDown(Key.LEFT) && this._x > 0) {
        _x -= 5;
    }
    if (Key.isDown(Key.RIGHT) && this._x < 550) {
        _x += 5;
    }
}

and i can move it. I have made a simple square. I named the square (movieclip) wall. Now what should i add to this code:

onClipEvent (enterFrame) {
    if (Key.isDown(Key.UP) && this._y >0) {
        _y -= 5;
    }
    if (Key.isDown(Key.DOWN) && this._y <400) {
        _y += 5;
    }
    if (Key.isDown(Key.LEFT) && this._x > 0) {
        _x -= 5;
    }
    if (Key.isDown(Key.RIGHT) && this._x < 550) {
        _x += 5;
    }
}

to my "hero" - circle cannot pass the wall?

Offline

 

#5 26/04/09 11:32am

kamac
Member
Registered: 21/04/09
Posts: 13

Re: Walking stick .fla

ppl plz help me i rly need help

Offline

 

#6 26/04/09 1:17pm

g0ofygoober
Hardcore Member
Registered: 28/10/08
Posts: 194
Website

Re: Walking stick .fla

theres some good tutorials over at tutorialized that could probably explain it better than we could

Offline

 

#7 26/04/09 1:47pm

alfarts
Hardcore Member
Registered: 27/01/08
Posts: 180

Re: Walking stick .fla

we dont really have that type of experience with that, so do what goofygoober said to do.


HERE ARE SOME OF MY VIDEO GAME ACHEIVEMENTS:
Beat Thrillville off the Rails (PSP), Class A car license on Burnout Paradise (PS3) and 12 gold medals out of 13 on wipEout purE (PSP)
those are some of my acheivements in playing video games.
shakehead smile big_smile big_smile cheer

Offline

 

#8 26/04/09 1:47pm

alfarts
Hardcore Member
Registered: 27/01/08
Posts: 180

Re: Walking stick .fla

we dont really have that type of experience with that, so do what goofygoober said to do.


HERE ARE SOME OF MY VIDEO GAME ACHEIVEMENTS:
Beat Thrillville off the Rails (PSP), Class A car license on Burnout Paradise (PS3) and 12 gold medals out of 13 on wipEout purE (PSP)
those are some of my acheivements in playing video games.
shakehead smile big_smile big_smile cheer

Offline

 

#9 26/04/09 1:48pm

alfarts
Hardcore Member
Registered: 27/01/08
Posts: 180

Re: Walking stick .fla

we dont really have that type of experience with that, so do what goofygoober said to do.


HERE ARE SOME OF MY VIDEO GAME ACHEIVEMENTS:
Beat Thrillville off the Rails (PSP), Class A car license on Burnout Paradise (PS3) and 12 gold medals out of 13 on wipEout purE (PSP)
those are some of my acheivements in playing video games.
shakehead smile big_smile big_smile cheer

Offline

 

#10 26/04/09 6:31pm

tenjimaru
Moderator
From: SD-CA
Registered: 30/03/08
Posts: 679

Re: Walking stick .fla

Do a google search for tutorials, its faster to get an answer.
to block movement you need to make a hitTest, its easy...
put this on your character:
onClipEvent (enter frame) {
if (this.hitTest(_root.WALL)
_y += 5)
}
if (this.hitTest(_root.WALL)
_y -= 5)
}
if (this.hitTest(_root.WALL)
_x +=5)
}
if (this.hitTest(_root.WALL)
_x -=5
}
}
@ alfarts.... please dont speak for everyone in the forum... big_smile


[i]cookie Tenebra Crystallis.. Released!
Portable Fishing 2012 Released!
Find Them In The 'Flash Games' Section of The Forums[/i]

Offline

 

#11 26/04/09 9:27pm

alfarts
Hardcore Member
Registered: 27/01/08
Posts: 180

Re: Walking stick .fla

ok, sry bout that. umm.. sry bout triple posts didnt mean to do that..


HERE ARE SOME OF MY VIDEO GAME ACHEIVEMENTS:
Beat Thrillville off the Rails (PSP), Class A car license on Burnout Paradise (PS3) and 12 gold medals out of 13 on wipEout purE (PSP)
those are some of my acheivements in playing video games.
shakehead smile big_smile big_smile cheer

Offline

 

#12 27/04/09 3:50pm

kamac
Member
Registered: 21/04/09
Posts: 13

Re: Walking stick .fla

tenjimaru when i put only this script i cannot move. I mean of something like hitTest -
if (this.hitTest(_root.WALL) {
and there script to push player off the wall. like _x -= 1; or something like that.

Offline

 

#13 27/04/09 4:07pm

HankJFox
Hardcore Member
Registered: 21/04/09
Posts: 117

Re: Walking stick .fla

You don't need script to push player off the wall. I recommend placing hitTest before moving the character. Test if upcoming movement _would_ hit walls, and if it does, do not move the character. Much easier.


Calamity RPG status: Back on track. Wonder where it leads.

Offline

 

#14 27/04/09 5:18pm

g0ofygoober
Hardcore Member
Registered: 28/10/08
Posts: 194
Website

Re: Walking stick .fla

*sigh* tongue ok tenj there are quite a few misakes in your code the full code should look like this:

onClipEvent (enterFrame) {
    if (Key.isDown(Key.UP)  && this.hitTest(_root.topwall)==false) {
        _y -= 5;
    }
    if (Key.isDown(Key.DOWN) && this.hitTest(_root.bottomwall)==false) {
        _y += 5;
    }
    if (Key.isDown(Key.LEFT) && this.hitTest(_root.leftwall)==false) {
        _x -= 5;
    }
    if (Key.isDown(Key.RIGHT) && this.hitTest(_root.rightwall)==false) {
        _x += 5;
    }
}

or this:

onClipEvent (enterFrame) {
    if (Key.isDown(Key.UP)) {
        _y -= 5;
    }
    if (Key.isDown(Key.DOWN)) {
        _y += 5;
    }
    if (Key.isDown(Key.LEFT)) {
        _x -= 5;
    }
    if (Key.isDown(Key.RIGHT)) {
        _x += 5;
    }

    if (this.hitTest(_root.topwall)) {
        _y += 5
    }
    if (this.hitTest(_root.bottemwall)) {
        _y -= 5)
    }
    if (this.hitTest(_root.leftwall)
        _x +=5)
    }
    if (this.hitTest(_root.rightwall)) {
        _x -=5
    }
}

there are other ways to do this but these would be the most common and simplest.  Both of these need 4 wall movieclips called topwall, bottemwall etc.

also try to understand the code before you use it that way you'll get to understand how actionscript works not just copying and pasting stuff you dont really know how to use wink

Offline

 

#15 27/04/09 9:39pm

tenjimaru
Moderator
From: SD-CA
Registered: 30/03/08
Posts: 679

Re: Walking stick .fla

OMFG! you are right i made a huge mistake.
i just checked my code and its totally different.
wow i was so tired i didnt even know what i was typing... =/

Last edited by tenjimaru (27/04/09 10:40pm)


[i]cookie Tenebra Crystallis.. Released!
Portable Fishing 2012 Released!
Find Them In The 'Flash Games' Section of The Forums[/i]

Offline

 

#16 29/04/09 12:54pm

kamac
Member
Registered: 21/04/09
Posts: 13

Re: Walking stick .fla

thx g0ofygoober smile u help me much smile
Next problem: i need a code: i have an dynamic text called a. I need an script what change text of "a" i mean add a point for player like +1. When i have 0 points i will have 1 when i have 11 i will have 12. And a script something like this:
if (a(my text)number == 12) {
               there my script
} sum 1 should know

Last edited by kamac (29/04/09 1:24pm)

Offline

 

#17 29/04/09 10:01pm

shinsukeito
The Explorer
From: Bloody Australia.
Registered: 23/09/08
Posts: 605

Re: Walking stick .fla

Well I put an instance name on the text (I think) and then I put this on as script:

onClipEvent(enterFrame) {
if(_root.a = 12) {
//Script
}
}

Sorry if it wasn't much help!
Good luck with your game!

Last edited by shinsukeito (29/04/09 10:04pm)


[img]http://dl.dropbox.com/u/1140693/sig.png[/img]

Offline

 

#18 29/04/09 11:58pm

alfarts
Hardcore Member
Registered: 27/01/08
Posts: 180

Re: Walking stick .fla

we hope... nvm.


HERE ARE SOME OF MY VIDEO GAME ACHEIVEMENTS:
Beat Thrillville off the Rails (PSP), Class A car license on Burnout Paradise (PS3) and 12 gold medals out of 13 on wipEout purE (PSP)
those are some of my acheivements in playing video games.
shakehead smile big_smile big_smile cheer

Offline

 

#19 01/05/09 9:47pm

g0ofygoober
Hardcore Member
Registered: 28/10/08
Posts: 194
Website

Re: Walking stick .fla

glad to see i helped smile
for a dinamic text you need to give it a variable name of "a". its in the properties pannel in Var: otherwise it will treat it the same as a movieclip. then you just treat it like any other variable.

Last edited by g0ofygoober (01/05/09 10:02pm)

Offline

 

#20 02/05/09 8:49am

kamac
Member
Registered: 21/04/09
Posts: 13

Re: Walking stick .fla

shinsukeito u helped me much wink

Offline

 

#21 02/05/09 9:49am

shinsukeito
The Explorer
From: Bloody Australia.
Registered: 23/09/08
Posts: 605

Re: Walking stick .fla

No problem!

Hope to see your game in the near future!


[img]http://dl.dropbox.com/u/1140693/sig.png[/img]

Offline

 

#22 05/05/09 12:42pm

kamac
Member
Registered: 21/04/09
Posts: 13

Re: Walking stick .fla

I need an command for setting x and y of mouse :} anyone know this command? :S

PS.
and i need an command like:
if MYCLIPNAME is frame 3;
//my code

Last edited by kamac (05/05/09 12:49pm)

Offline

 

#23 06/05/09 5:39am

shinsukeito
The Explorer
From: Bloody Australia.
Registered: 23/09/08
Posts: 605

Re: Walking stick .fla

I don't think you can actually control the mouse... but you could make a fake mouse or something.


[img]http://dl.dropbox.com/u/1140693/sig.png[/img]

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson