collide with tween



  • Hello,

    I load tilemap collision and i want to make a move with tween of 16px in x .
    but my character dont collide.

    i use FlxG.collide(character, map);

    how to do it ?

    i want a move style of pokemon red on GB. Thanks



  • I solved it. I move my character with my fonction.

    exemple of one direction

    // check if player touching collision map
    switch this.touching
    {
         case FlxObject.NONE:    // nothing to do when no collision
         default:                moving = false; this.animation.reset();
     }
    
    super.update(elapsed);
    
    // move character by direction
    switch direction
    {
         case Direction.Left:    if(this.x > destinationMove.x)
                                 {
                                      this.animation.play("walk-left");
    
                                      if(this.x <= FlxG.worldBounds.x)
                                      {
                                           this.x = 0;
                                           this.moving = false;
                                           this.animation.reset();
                                      }
                                      else
                                      {
                                           this.x -= speed;
                                      }
                                 }
                                 else
                                 {
                                      this.animation.reset();
                                      this.x = pPosition.x;
                                      this.moving = false;
                                 };
    }
    
    // set next destination
    if(walkLeft.triggered && !moving)
    {
         this.destinationMove = new FlxPoint(this.x - 16, this.y);
         this.direction = Direction.Left;
         this.moving = true;
    }
    

Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.