Go Back   kirupaForum > Flash > ActionScript 3.0

Reply
 
Thread Tools Display Modes
Old 11-29-2009, 02:01 AM   #1
ash_at_risk
Registered User
[help]platform game,character stops earlier before collision to right wall

hi guys,
I m under the process to create a platform based game,but stuck in a problem ,its probably concern with x-axis, actually my player stops certain distance before right wall and with left wall too,i tried to reduce the distance but end up in failure,i have attached the concern fla.

PHP Code:
function moveman(Char:Objecttimediff:int)
        {
            if(
timediff<1)
            return;
            var 
vertical:Number=Char.dy gravity*timediff;  
            if (
vertical>15.0)
            
vertical=15.0;
                
Char.dy+= timediff*gravity;
                var 
horizontalDist:Number=0;
                var 
newDirection:int=Char.direction;
                var 
newAnimstate:String="stand";
                if (
Char.moveLeft)
                {
                    
horizontalDist=-Char.walkspeed timediff;
                    
newAnimstate="walk";
                    
newDirection=-1;
                }
                else if(
Char.moveRight)
                {    
                    
horizontalDist=Char.walkspeed*timediff;
                    
newAnimstate="walk";
                    
newDirection=1;
                }
                 if(
Char.jump)
                {
                    
Char.jump=false;
                    
Char.dy=-Char.jumpspeed;
                    
vertical=-Char.jumpspeed;
                    
newAnimstate="jump";
                }
 
                var 
newY:Number=  Char.mc.vertical;
                var 
newX:NumberChar.mc.xhorizontalDist;
                
Char.inAir=true;
    for (var 
j:int=0;j<wal.lengthj++)
    {  
            if ((
Char.mc.x+Char.width/>wal[j].leftside) && (Char.mc.x-Char.width/2<wal[j].rightside))   
            { 
                   if ((
Char.mc.y  <= wal[j].topside)&& (newY>wal[j].topside))
                { 
                    
newY=wal[j].topside-Char.width;
                    
Char.inAir=false;
                    
Char.dy=0;
                    break;
                }
               }
            }
   for (var 
j:int=0j<wal.lengthj++)
   {
     if((
newY>wal[j].topside)&&(newY-Char.height<
wal[j].bottomside))
    {
     if (( (
Char.mc.xChar.width/2) >=wal[j].rightside) && ((newX-Char.width/)<= wal[j].rightside))
        {    
            
newX=wal[j].rightside Char.width/2;
            break;
        }
         if(((
Char.mc.x+Char.width/2)<=wal[j].leftside) && (newX +Char.width/2>=wal[j].leftside))
        {
            
newX=wal[j].leftside-Char.width/2;
            break;
        }
    }                    
  }
               
Char.mc.x=newX;
                
Char.mc.y=newY;
      } 
Attached Files
File Type: zip sound2.zip (98.2 KB, 0 views)

Last edited by ash_at_risk; 11-29-2009 at 02:23 AM..
ash_at_risk is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Old 11-29-2009, 02:19 AM   #2
dandylion13
Registered User
Is this bit of code correct?

if((newY>wal[j].topside)&&(newY-Char.height<
wa[j].bottomside))


It looks like there's an "l" missing from "wal" ...?
dandylion13 is offline   Reply With Quote
Old 11-29-2009, 02:42 AM   #3
ash_at_risk
Registered User
Sorry i have corrected it.Rest is fine
ash_at_risk is offline   Reply With Quote
Old 11-29-2009, 04:37 AM   #4
dandylion13
Registered User
Are your "wal" objects perfectly centered at 0,0 ?
dandylion13 is offline   Reply With Quote
Old 11-29-2009, 04:55 AM   #5
ash_at_risk
Registered User
I accidently discovered what a blunder i did, Inside my actionscript panel i mentioned object man width=50;
man.width=50;
but in the properties panel of flash, i mention
man.width=15.6;
I was thinking of man.width=15.6 , but everytime it get a value man.width=50;
Finally everthing is almost correct
Thanks a ton dandylion
Attached Files
File Type: zip sound2.zip (109.8 KB, 0 views)
ash_at_risk is offline   Reply With Quote
Old 11-29-2009, 05:06 AM   #6
dandylion13
Registered User
Cool, glad you found it
dandylion13 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:59 AM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com