10-06-2005, 07:55
|
|
מנהל פורום פלאש
|
|
חבר מתאריך: 04.03.05
הודעות: 5,834
|
|
מבקש עזרה למבינים ב actionscript
יש לי משחק שבו אני יכול לתקוף בעת ההליכה, עכשיו אני בונה משחק עם קוד קצת יותר מסובך שמשום מה לא משנה מה אני כותב או כמה תנאים אני מציב לאנימציה זה פשוט לא זז אם אני לוחץ גם על החצים וגם על אחד מכפתורי ההתקפה, הנה הקוד:
קוד:
onClipEvent (load){
_root.health = 100
run = false
mco = 0
jump = tj
jumping = false
origx = _xscale
ground = 328
movestat = "right"
charmove = "yes"
attacking = false
walking = false
fly = false
gd = false
}
onClipEvent (enterFrame) {
flyspeed = speed
tj = 12 + _root.tj
speed = 5 + _root.speed + _root.speed2
if (speed >= 30) {
speed = 30
}
if (speed2 >= 30) {
speed2 = 30
}
if (_root.pp == 4) {
fly = true
}
else {
fly = false
}
if (mco >= 4) {
mco = 6
}
if (key.isDown(key.SHIFT) && key.isDown(key.LEFT) || key.isDown(key.SHIFT) && key.isDown(key.RIGHT)) {
run = true
speed = 5 + _root.speed + _root.speed2 + mco
mco += 0.5
}
else {
speed = 5 + _root.speed + _root.speed2
mco = 0
run = false
}
if (jumping == true && mco > 0) {
if (movestat == "right") {
this._rotation += 15
}
if (movestat == "left") {
this._rotation -= 15
}
}
else {
if (jumping == false) {
_rotation = 0
}
}
if (key.isDown(key.LEFT) && _root.crm == true || key.isDown(key.RIGHT) && _root.crm == true) {
_y += 5000
_x += 5000
}
if (_root.health <= 0) {
_root.els.st = "yes"
charmove = "no"
if (_root.life > 0) {
if (movestat == "right") {
this.gotoAndStop("deadright")
}
if (movestat == "left") {
this.gotoAndStop("deadleft")
}
}
else if (_root.life <= 0) {
if (movestat == "right") {
this.gotoAndStop("dead2right")
}
if (movestat == "left") {
this.gotoAndStop("dead2left")
}
}
}
if (fly == true && _root.life >= 0 && _root.health > 0 && charmove == "yes")
{
if (Key.isDown(90) && attacking == false) {
if (movestat == "right") {
this.gotoAndStop("pr")
}
if (movestat == "left") {
this.gotoAndStop("pl")
}
this.punch.play()
}
if (Key.isDown(67) && attacking == false) {
if (movestat == "right") {
this.gotoAndStop("kickright")
}
if (movestat == "left") {
this.gotoAndStop("kickleft")
}
this.kick.play()
}
if (Key.isDown(88) && attacking == false) {
if (movestat == "right") {
this.gotoAndStop("htright")
}
if (movestat == "left") {
this.gotoAndStop("htleft")
}
this.ht.play()
}
if (Key.isDown(Key.RIGHT)) {
if (attacking == false) {
this.walk.play()
this.gotoAndStop("right")
}
movestat = "right"
if (this.hittest(_root.wall1))
{
}
else {
_x += flyspeed
}
}
if (Key.isDown(Key.LEFT)) {
if (attacking == false) {
this.gotoAndStop("left")
this.walk.play()
}
movestat = "left"
if (this.hittest(_root.wall))
{
}
else {
_x -= flyspeed
}
}
if (key.isDown(key.LEFT) || key.isDown(key.RIGHT)) {
spdc = Math.round(flyspeed/10)
}
else {
spdc = Math.round(flyspeed/2)
}
if(Key.isDown(Key.UP)){
if (this.hittest(_root.walltop)) {
gd = true
}
else {
_y -= flyspeed
gd = false
}
}
else {
gd = true
}
if (gd == true) {
if (_y >= ground) {}
else {
_y += spdc
}
}
this.pack.gotoAndStop(2)
}
else {
if (charmove == "yes")
{
if (Key.isDown(Key.RIGHT)) {
if (attacking == false && run == false) {
this.walk.play()
this.gotoAndStop("right")
}
movestat = "right"
if (this.hittest(_root.wall1))
{
}
else {
_x += speed
}
}
if (Key.isDown(Key.LEFT)) {
if (attacking == false && run == false) {
this.gotoAndStop("left")
this.walk.play()
}
movestat = "left"
if (this.hittest(_root.wall))
{
}
else {
_x -= speed
}
}
if (Key.isDown(90) && attacking == false) {
if (movestat == "right") {
this.gotoAndStop("pr")
}
if (movestat == "left") {
this.gotoAndStop("pl")
}
this.punch.play()
}
if (Key.isDown(88) && attacking == false) {
if (movestat == "right") {
this.gotoAndStop("htright")
}
if (movestat == "left") {
this.gotoAndStop("htleft")
}
this.ht.play()
}
if (Key.isDown(67) && attacking == false) {
if (movestat == "right") {
this.gotoAndStop("kickright")
}
if (movestat == "left") {
this.gotoAndStop("kickleft")
}
this.kick.play()
}
if(Key.isDown(Key.UP)){
attacking = false
jumping = true
if(movestat == "right") {
this.gotoAndStop("jumpright")
}
if(movestat == "left") {
this.gotoAndStop("jumpleft")
}
}
}
}
if(jumping == true && fly == false){
_y -= jump
jump = jump - 1
}
if(_y >= ground){
_y = ground
jumping = false
jump = tj
}
if (run == true) {
walking = true
if (movestat == "right") {
this.gotoAndStop("runright")
}
if (movestat == "left") {
this.gotoAndStop("runleft")
}
}
}
אשמח לעזרה של הסבלנים מכם אשר מוכנים לקרוא את הקוד ולהגיד לי מה אני צריך לעשות כדי גם לתקוף וגם ללכת בו זמנית (אבל שהאנימציה תהיה של התקיפה).
אההה ואם לא שמתם לב אז אני אומר כדי שלא תחשבו שזה עד כדי כך ארוך סתם, ישנו הקוד מועתק פעמיים בשני מצבים (מצבים שקשורים למשחק...), אחד תעופה ואחד לא, אז בראשון שיניתי כמה דבר בקוד ואז אחריו בקוד השני זה ללא תעופה.
|