Ignore:
Timestamp:
2016-07-02 23:19:28 (3 years ago)
Author:
sieerinn
Message:

Hajotettavia palikoita

Location:
2016/27/SimoR/SimplePhysicsTest/SimplePhysicsTest
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 2016/27/SimoR/SimplePhysicsTest/SimplePhysicsTest/SimplePhysicsTest/SimplePhysicsTest.cs

    r7643 r7644  
    127127        tilemap.SetTileMethod(Color.FromHexCode("FFFF00"), CreateMovingPlatform); 
    128128        tilemap.SetTileMethod(Color.FromHexCode("B70909"), CreateDangerousBlock); 
     129        tilemap.SetTileMethod(Color.FromHexCode("FFB949"), CreateDestroyableBrick); 
    129130        tilemap.SetTileMethod(Color.Blue, CreatePlayer); 
    130131        tilemap.SetTileMethod(Color.Red, CreateEnemy); 
     
    160161        Add(tile); 
    161162        SetTile(x, y, tile); 
     163    } 
     164 
     165    private void CreateDestroyableBrick(int x, int y) 
     166    { 
     167        var tile = new SimplePhysics.Object(TileSize, TileSize) { IsStatic = true }; 
     168        tile.Color = Color.Orange; 
     169        tile.Tag = "brick"; 
     170        Add(tile); 
     171        SetTile(x, y, tile); 
     172 
     173        tile.AddCollisionHandler("player", (t, player) => 
     174        { 
     175            if (player.Top <= tile.Bottom) 
     176            { 
     177                tile.Destroy(); 
     178            } 
     179        }); 
    162180    } 
    163181 
Note: See TracChangeset for help on using the changeset viewer.