本文整理汇总了C#中Layer.AddActor方法的典型用法代码示例。如果您正苦于以下问题:C# Layer.AddActor方法的具体用法?C# Layer.AddActor怎么用?C# Layer.AddActor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layer
的用法示例。
在下文中一共展示了Layer.AddActor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadLevel
//.........这里部分代码省略.........
// ---- Read the actor data
//Create a new Actor instance
Actor actor = null;
//Get the actor's ID
int ID = file.ReadInt32( );
//Get the sprite name
string spriteName = file.ReadString( );
//Get the script name
scriptName = file.ReadString( );
if( scriptName != GameManager.NO_SCRIPT )
{
Type type = _gameManager.GetClassType( scriptName );
if( type != null )
actor = Activator.CreateInstance( type ) as Actor;
}
if( actor == null )
actor = new Actor( );
actor.ID = ID;
//Assign the correct sprite to the actor if a match is found
if( Sprites.ContainsKey( spriteName ) )
actor.Sprite = Sprites[spriteName];
//Get and assign the name of the actor
actor.Name = file.ReadString( );
//Get and assign the actor's position
actor.Position = new Vector2( file.ReadSingle( ), file.ReadSingle( ) );
//Get and assign the actor's origin
actor.Origin = new Vector2( file.ReadSingle( ), file.ReadSingle( ) );
//Get and assign the actor's scale
actor.Scale = file.ReadSingle( );
//Get and assign the actor's rotation angle
actor.Rotation = file.ReadSingle( );
//Get and assign the actor's visibility
actor.Visible = file.ReadBoolean( );
if( levelVersion >= 3 )
{
int tagCount = file.ReadInt32( );
for( int k = 0; k < tagCount; k++ )
{
actor.AddTag( file.ReadString( ) );
}
bool isTextActor = file.ReadBoolean( );
if( isTextActor )
{
if( ( actor as TextActor ) == null )
{
TextActor txtActor = new TextActor( );
actor.CopyValues( txtActor );
actor = txtActor;
}
string fontName = file.ReadString( );
if( Fonts.ContainsKey( fontName ) )
( actor as TextActor ).Font = Fonts[fontName];
( actor as TextActor ).Text = file.ReadString( );
( actor as TextActor ).TextColor = new Color( file.ReadByte( ), file.ReadByte( ), file.ReadByte( ), file.ReadByte( ) );
}
}
//Add the actor to the layer
layer.AddActor( actor );
}
//Add the layer instance to the level
lvl.NewLayer( layer );
}
file.Close( );
lvl.Game = this;
ActiveLevel = lvl;
}
LevelLoaded( );
ActiveLevel.Init( );
foreach( Layer layer in ActiveLevel.Layers.Values )
{
foreach( Actor actor in layer.Actors )
{
actor.Init( );
}
}
}