本文整理汇总了C++中TextActor类的典型用法代码示例。如果您正苦于以下问题:C++ TextActor类的具体用法?C++ TextActor怎么用?C++ TextActor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextActor类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetNaturalSize
Vector3 GetNaturalSize( Actor actor )
{
Vector3 size = actor.GetCurrentSize();
const float depth = size.depth;
// Get natural size for TextActor.
TextActor textActor = TextActor::DownCast( actor );
if( textActor )
{
Font font = textActor.GetFont();
if( !font )
{
font = Font::New();
}
size = font.MeasureText( textActor.GetText() );
size.depth = depth;
}
// Get natural size for ImageActor.
// TODO: currently it doesn't work as expected.
ImageActor imageActor = ImageActor::DownCast( actor );
if( ( imageActor ) && ( imageActor.GetImage() ) )
{
Image image = imageActor.GetImage();
size = Vector3( static_cast<float>( image.GetWidth() ), static_cast<float>( image.GetHeight() ), depth );
}
return size;
}
开发者ID:Tarnyko,项目名称:dal-toolkit,代码行数:29,代码来源:relayout-helper.cpp
示例2: a
void DemoScreenConsole::Start()
{
//Place the actor from a definition file
localActor = a = Actor::Create("simple_actor");
theWorld.Add(a);
//Give it a name that our script hooks can latch onto.
a->SetName("ForDemoConsole");
//Demo housekeeping below this point.
#pragma region Demo housekeeping
String explanation = "This demo shows off the console.";
explanation += "\n\nPress ~ to open it up. Execute \"add_texture()\", enjoying the tab-completion.";
explanation += "\nThen try executing \"change_size(3.14)\" or whatever number suits your fancy.";
explanation += "\n\nThe console is a (nearly) fully functional Python interpreter.";
explanation += "\nThe sample functions are defined in \"Resources/Scripts/client_start.py\".";
t = new TextActor("Console", explanation);
t->SetPosition(0, -3.5f);
t->SetAlignment(TXT_Center);
theWorld.Add(t);
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenConsole.cpp, demo_actors.ini, client_start.py");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t);
_objects.push_back(a);
#pragma endregion
}
开发者ID:chrishaukap,项目名称:GameDev,代码行数:35,代码来源:DemoScreenConsole.cpp
示例3: GetHeightForWidth
float GetHeightForWidth( Actor actor, float width )
{
Vector3 size = actor.GetCurrentSize();
float height = 0.f;
TextActor textActor = TextActor::DownCast( actor );
if( textActor )
{
Font font = textActor.GetFont();
if( !font )
{
font = Font::New();
}
size = font.MeasureText( textActor.GetText() );
}
ImageActor imageActor = ImageActor::DownCast( actor );
if( ( imageActor ) && ( imageActor.GetImage() ) )
{
Image image = imageActor.GetImage();
size = Vector3( static_cast<float>( image.GetWidth() ), static_cast<float>( image.GetHeight() ), 0.f );
}
height = size.height / ( size.width / width );
return height;
}
开发者ID:Tarnyko,项目名称:dal-toolkit,代码行数:27,代码来源:relayout-helper.cpp
示例4: TextActor
void DemoScreenLayeredCollisionLevelFile::Start()
{
//Give names to some layers so we can reference them more easily
theWorld.NameLayer("background", 0);
theWorld.NameLayer("foreground", 1);
theWorld.NameLayer("hud", 2);
//Loads the file from Config\ActorDef\layeredcollisionlevel_demo.lua
theWorld.LoadLevel("layeredcollisionlevel_demo");
//All the magic happens in the level file!
//Demo housekeeping below this point.
#pragma region Demo housekeeping
t2 = new TextActor("Console", "These new Actors were assigned layers in their level file.");
t2->SetPosition(0, 5.5);
t2->SetAlignment(TXT_Center);
theWorld.Add(t2, 10);
t3 = new TextActor("Console", "Layers can be given string names as well as numbers");
t3->SetPosition(0, 4.5);
t3->SetAlignment(TXT_Center);
theWorld.Add(t3, 10);
t4 = new TextActor("Console", "and assigned to Actors in their definition file or at runtime.");
t4->SetPosition(0, 3.5);
t4->SetAlignment(TXT_Center);
theWorld.Add(t4, 10);
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenLayeredCollisionLevelFile.cpp, layeredcollisionlevel_demo.lua");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc, 10);
_objects.push_back(fileLoc);
_objects.push_back(t2);
_objects.push_back(t3);
_objects.push_back(t4);
ActorSet spawnedActors = theTagList.GetObjectsTagged("spawned");
ActorSet::iterator it = spawnedActors.begin();
while (it != spawnedActors.end())
{
_objects.push_back(*it);
it++;
}
#pragma endregion
}
开发者ID:CmPons,项目名称:angel2d,代码行数:47,代码来源:DemoScreenLayeredCollisionLevelFile.cpp
示例5: ParticleActor
void DemoScreenParticleActors::Start()
{
// Create the particle actor via the Actor Definition system (.adf files)
pa = new ParticleActor();
pa->SetColor(1.0f, 1.0f, 1.0f); //Sets the initial color of the particles.
// Since the image file we'll be using already
// has a color, we set this to pure white.
pa->SetSize(Vector2(0.2f, 0.2f)); //The size of each particle, in GL units
pa->SetSprite("Resources/Images/Test.png"); //The image file we want to use (otherwise
// it'll just be colored squares).
pa->SetMaxParticles(500); //The maximum number of particles this system will ever handle.
pa->SetParticlesPerSecond(10.0f); //Emission Rate
pa->SetParticleLifetime(1.5f); //How long each particles lasts before disappearing
pa->SetSpread(MathUtil::Pi); //The angle in radians at which particles will be emitted.
pa->SetEndScale(1.0f); //If you want the particles to change size over their lifetimes
Color endColor(1.0f, 1.0f, 1.0f, 0.0f);
pa->SetEndColor(endColor); //Our particles disappear over time
pa->SetEndScale(2.0f);
pa->SetSpeedRange(3.0f, 4.0f); //The minimum and maximum range of speeds (so you can have
// some variation).
pa->SetGravity(Vector2::Zero); //You can pull the particles in a particular direction (default is
// downwards, so zero it out if you need to).
theWorld.Add(pa);
_isActive = true; //lets the mouse events know that they should care
//Demo housekeeping below this point.
#pragma region Demo Housekeeping
t = new TextActor("Console", "Here's a ParticleActor. (Try moving and clicking the mouse!)");
t->SetPosition(0, 3.5);
t->SetAlignment(TXT_Center);
theWorld.Add(t);
t2 = new TextActor("Console", "Press [B] to change its properties.");
t2->SetPosition(0, 2.5);
t2->SetAlignment(TXT_Center);
theWorld.Add(t2);
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenParticleActors.cpp");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t);
_objects.push_back(t2);
_objects.push_back(pa);
#pragma endregion
}
开发者ID:chrishaukap,项目名称:GameDev,代码行数:47,代码来源:DemoScreenParticleActors.cpp
示例6: Actor
void DemoScreenMultipleControllers::Start()
{
//Create two Actors that we're going to manipulate with the two
// controllers. All the actual interesting stuff happens in the
// DemoScreenMultipleControllers::Update function.
a = new Actor();
a->SetSize(4.0f);
a->SetPosition(-4.0f, 0.0f);
a->SetColor(1.0f, 1.0f, 0.0f, 0.5f);
theWorld.Add(a);
a2 = new Actor();
a2->SetSize(4.0f);
a2->SetPosition(4.0f, 0.0f);
a2->SetColor(1.0f, 1.0f, 0.0f, 0.5f);
theWorld.Add(a2);
//Demo housekeeping below this point.
#pragma region Demo Housekeeping
t = new TextActor("Console", "These two actors are connected to different controllers.");
t->SetPosition(0, 3.5);
t->SetAlignment(TXT_Center);
t2 = new TextActor("Console", "You can use multiple controllers for two-player games.");
t2->SetPosition(0, -4);
t2->SetAlignment(TXT_Center);
t3 = new TextActor("Console", "(If you only have one [or zero] controllers connected, \nthis screen is kind of boring.)");
t3->SetPosition(0, -8);
t3->SetAlignment(TXT_Center);
theWorld.Add(t);
theWorld.Add(t2);
theWorld.Add(t3);
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenMultipleControllers.cpp");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t);
_objects.push_back(t2);
_objects.push_back(t3);
_objects.push_back(a);
_objects.push_back(a2);
#pragma endregion
}
开发者ID:CmPons,项目名称:angel2d,代码行数:46,代码来源:DemoScreenMultipleControllers.cpp
示例7: Actor
void DemoScreenRenderLayers::Start()
{
//Create overlapping actors
a1 = new Actor();
a1->SetSize(5.0f);
a1->SetColor(0,0,1);
a1->SetPosition(-1, -1);
a2 = new Actor();
a2->SetSize(5.0f);
a2->SetColor(1,0,0);
a2->SetPosition(1, 1);
theWorld.Add(a1, 0); //Adding this actor to layer 0
theWorld.Add(a2, 1); //Adding this actor to layer 1
//For your game, you may want to use an enum
// or name the layers (see World.cpp or the later
// DemoScreenLayeredCollisionLevelFile.cpp for more
// information).
//Demo housekeeping below this point.
#pragma region Demo Housekeeping
t1 = new TextActor("Console", "These Actors overlap.");
t1->SetPosition(0, 5.5);
t1->SetAlignment(TXT_Center);
theWorld.Add(t1);
t2 = new TextActor("Console", "Use the controller's bumper buttons or \nthe right and left arrow keys to change their layer ordering.");
t2->SetPosition(0, 4.5);
t2->SetAlignment(TXT_Center);
theWorld.Add(t2);
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenRenderLayers.cpp");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t1);
_objects.push_back(t2);
_objects.push_back(a1);
_objects.push_back(a2);
#pragma endregion
}
开发者ID:MaliusArth,项目名称:PixelArth,代码行数:46,代码来源:DemoScreenRenderLayers.cpp
示例8: dbgPrint
void dbgPrint( const WordLayoutInfo& word )
{
for( CharacterLayoutInfoContainer::const_iterator characterIt = word.mCharactersLayoutInfo.begin(), endCharacterIt = word.mCharactersLayoutInfo.end();
characterIt != endCharacterIt;
++characterIt )
{
const CharacterLayoutInfo& character( *characterIt );
std::cout << "[" << character.mSize << std::endl;
std::cout << " ascender " << character.mAscender << std::endl;
TextActor textActor = TextActor::DownCast( character.mGlyphActor );
if( textActor )
{
std::cout << "[" << textActor.GetText() << "]";
}
else
{
std::cout << "[ImageActor]" << std::endl;
}
std::cout << "{" << character.mStyledText.mText.GetText() << "}";
}
std::cout << " size " << word.mSize << std::endl;
std::cout << " ascender " << word.mAscender << std::endl;
std::cout << " num char " << word.mCharactersLayoutInfo.size() << std::endl;
std::cout << " type ";
switch( word.mType )
{
case NoSeparator:
{
std::cout << "NoSeparator" << std::endl;
break;
}
case LineSeparator:
{
std::cout << "LineSeparator" << std::endl;
break;
}
case WordSeparator:
{
std::cout << "WordSeparator" << std::endl;
break;
}
}
}
开发者ID:Tarnyko,项目名称:dal-toolkit,代码行数:45,代码来源:text-view-processor-dbg.cpp
示例9: IntToString
void Shape::collectOrb(PhysicsActor* orb) {
String orb_name = orb->GetName();
sysLog.Log("Collected Orb: " + orb_name);
_inventory->add_orb();
int num_orbs = _inventory->total_orbs();
String s = "Total orbs: " + IntToString(num_orbs);
sysLog.Log(s);
theSound.PlaySound(_orbSound, 1.0f);
if (num_orbs == 6) {
TextActor* t = new TextActor("Console", "You beat the game!", TXT_Center);
Vector2 blocky_pos = GetPosition();
t->SetPosition(blocky_pos.X, blocky_pos.Y + 5.0f);
theWorld.Add(t, 2);
}
}
开发者ID:nofxboy1234,项目名称:sa,代码行数:19,代码来源:Shape.cpp
示例10: TextActor
void DemoScreenControllerInstructions::Start()
{
//Some TextActors warning you of the hazards to come.
String explanation = "These next two screens show how we get input from an Xbox 360 controller";
explanation += "\n\nIf you don't have or don't care about the controller, ";
explanation += "\nthey'll be a little boring. Feel free to skip.";
TextActor *t = new TextActor("Console", explanation);
t->SetPosition(0, 3.5);
t->SetAlignment(TXT_Center);
theWorld.Add(t);
//Demo housekeeping below this point.
#pragma region Demo housekeeping
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenControllerInstructions.cpp");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t);
#pragma endregion
}
开发者ID:MaliusArth,项目名称:PixelArth,代码行数:27,代码来源:DemoScreenControllerInstructions.cpp
示例11: TextActor
void DemoScreenByeBye::Start()
{
//"Goodnight, Gracie."
TextActor *t = new TextActor("Console", "That's all we've got in the demo app.");
t->SetPosition(0, 3.5);
t->SetAlignment(TXT_Center);
TextActor *t2 = new TextActor("Console", "Make sure to check out the documentation -- there are lots of other features.\n\nhttp://angel-engine.googlecode.com");
t2->SetPosition(0, 2);
t2->SetAlignment(TXT_Center);
TextActor *t3 = new TextActor("Console", "Press Esc to exit.");
t3->SetPosition(0, -1);
t3->SetAlignment(TXT_Center);
theWorld.Add(t);
theWorld.Add(t2);
theWorld.Add(t3);
//Demo housekeeping below this point.
#pragma region Demo housekeeping
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenByeBye.cpp");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t);
_objects.push_back(t2);
_objects.push_back(t3);
#pragma endregion
}
开发者ID:chrishaukap,项目名称:GameDev,代码行数:34,代码来源:DemoScreenByeBye.cpp
示例12: Actor
void DemoScreenMovingActor::Start()
{
//Set up the actor
a = new Actor();
a->SetSize(4.0f);
a->SetColor(1.0f, 1.0f, 0.0f, 0.5f);
theWorld.Add(a);
//Demo housekeeping below this point.
#pragma region Demo Housekeeping
t = new TextActor("Console", "This Actor gets moved around by the left thumbstick. Try it.");
t->SetPosition(0, 3.5);
t->SetAlignment(TXT_Center);
t2 = new TextActor("Console", "Press [B] to rotate him.");
t2->SetPosition(0, -4);
t2->SetAlignment(TXT_Center);
t3 = new TextActor("Console", "(The camera is a movable Actor, too -- right thumbstick.)");
t3->SetPosition(0, -8);
t3->SetAlignment(TXT_Center);
theWorld.Add(t);
theWorld.Add(t2);
theWorld.Add(t3);
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenMovingActor.cpp");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t);
_objects.push_back(t2);
_objects.push_back(t3);
_objects.push_back(a);
#pragma endregion
}
开发者ID:FlorianDeconinck,项目名称:angel2d,代码行数:37,代码来源:DemoScreenMovingActor.cpp
示例13: if
void LevelScreen::ReceiveMessage(Message* m)
{
if(m->GetMessageName() == "FoodConsumed")
{
std::stringstream ss;
m_highscoreCounter += m_snake->getPointMultiplicator();
ss << std::setfill('0') << std::setw(4) << m_highscoreCounter;
m_highscore->SetDisplayString(ss.str());
}
else if(m->GetMessageName() == "PowerupConsumed")
{
std::stringstream ss;
m_highscoreCounter += m_snake->getPointMultiplicator();
ss << std::setfill('0') << std::setw(4) << m_highscoreCounter;
Powerup* powerup = static_cast<Powerup*>(m->GetSender());
if(powerup != NULL)
{
m_popupText->SetColor(1.f, 1.f, 1.f);
m_popupText->SetDisplayString(powerup->getDescription());
m_popupText->ChangeColorTo(Color(1.0,0.0,0.0), 5.0, true, "HidePopup");
theWorld.Add(m_popupText, kUILayer);
}
}
else if(m->GetMessageName() == "HidePopup")
{
theWorld.Remove(m_popupText);
}
else if(m->GetMessageName() == "EnterPressed")
{
theSwitchboard.UnsubscribeFrom(this, "EnterPressed");
theSwitchboard.Broadcast(new Message("ShowMenu"));
}
else if(m->GetMessageName() == "ObstacleHit")
{
theWorld.Remove(m_popupText);
m_snake->stop();
TextActor* gameOver = new TextActor("popup", "GAME OVER");
gameOver->SetPosition(-4.8f, 4.0f);
gameOver->SetColor(1.f, 1.f, 1.f);
TextActor* hitEnterText = new TextActor("standard", "Hit [Enter] to get back to menu...");
hitEnterText->SetPosition(-8.8f, 0.0f);
hitEnterText->SetColor(1.f, 1.f, 1.f);
addRenderable(gameOver, kUILayer);
addRenderable(hitEnterText, kUILayer);
theSwitchboard.SubscribeTo(this, "EnterPressed");
}
}
开发者ID:d909b,项目名称:GADEL-Snake,代码行数:56,代码来源:LevelScreen.cpp
示例14: TextActor
void DemoScreenDefFile::Start()
{
//CreateActor loads up an Actor Definition file and makes the actor from it
a = Actor::Create("simple_actor"); //string is the file to load from --
// must be located in Config/ActorDef and end with ".lua"
//You still need to add it to the world after it's been created
theWorld.Add(a);
//Demo housekeeping below this point.
#pragma region Demo housekeeping
t = new TextActor("Console", "This Actor was placed using an archetype from an actor definition file.");
t->SetPosition(0, 4.5);
t->SetAlignment(TXT_Center);
theWorld.Add(t);
t2 = new TextActor("Console", "You can be data-driven if you want to!");
t2->SetPosition(0, 3.5);
t2->SetAlignment(TXT_Center);
theWorld.Add(t2);
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenDefFile.cpp, demo_actors.lua");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t);
_objects.push_back(t2);
_objects.push_back(a);
#pragma endregion
}
开发者ID:MaliusArth,项目名称:PixelArth,代码行数:36,代码来源:DemoScreenDefFile.cpp
示例15: Actor
void DemoScreenSimpleActor::Start()
{
//Creating a new, generic actor is simple.
a = new Actor();
//Sizes and coordinates are always in GL units, which can mean whatever you decide they mean
// -- our physics packages (Box2D) assumes that they mean meters, though.
a->SetSize(5.0f);
//R, G, B, [A]
a->SetColor(0,0,0);
//We have to add it to the world for it to be drawn. All Actors implement Update and Render
// methods that get called once per frame. All your logic should happen in the Update function,
// and you should only implement Render if you have to do something out of the ordinary.
theWorld.Add(a);
//Demo housekeeping below this point.
#pragma region Demo Housekeeping
t = new TextActor("Console", "Here's a simple Actor. (Press [B] to change it.)");
t->SetPosition(0, 3.5);
t->SetAlignment(TXT_Center);
theWorld.Add(t);
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenSimpleActor.cpp");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t);
_objects.push_back(a);
#pragma endregion
}
开发者ID:FlorianDeconinck,项目名称:angel2d,代码行数:36,代码来源:DemoScreenSimpleActor.cpp
示例16: bounds
void DemoScreenPathfinding::Start()
{
//Set up our obstacle course
theWorld.LoadLevel("maze");
//Create the bounding box that will limit the pathfinding search area
BoundingBox bounds(Vector2(-20, -20), Vector2(20, 20));
//Create our pathfinding graph. In our 2D worlds, this is a relatively fast
// operation -- you shouldn't be doing it every frame, but recalculating every
// so often if your world has changed is not inappropriate.
theSpatialGraph.CreateGraph(
0.75f, //The size of the entity you want to pathfind (so the generator
// can know how small a space can be and still have it fit.)
bounds //The search area
);
//Create a MazeFinder (class definition below), and put him in the bottom
// left corner of the maze
MazeFinder *mf = new MazeFinder();
mf->SetPosition(-11.5, -8);
theWorld.Add(mf);
//Send him to the upper right, watch him scurry
mf->GoTo(Vector2(11.5, 8));
//Demo housekeeping below this point.
#pragma region Demo housekeeping
String description = "This little dude is pathfinding through the area.";
description += "\n\nClick the mouse to give him a new target.";
description += "\n\nPress [B] to see the pathfinding graph.";
TextActor *t = new TextActor("Console", description);
t->SetAlignment(TXT_Center);
t->SetPosition(0.0f, -5.0f);
theWorld.Add(t);
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenPathfinding.cpp");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t);
_objects.push_back(mf);
ActorSet walls = theTagList.GetObjectsTagged("maze_wall");
ActorSet::iterator it = walls.begin();
while (it != walls.end())
{
_objects.push_back(*it);
it++;
}
#pragma endregion
}
开发者ID:chrishaukap,项目名称:GameDev,代码行数:53,代码来源:DemoScreenPathfinding.cpp
示例17: TextActor
void DemoScreenStart::Start()
{
//TextActors, oddly enough, let you display text!
TextActor *t = new TextActor("Console", "Welcome to Angel. This is a quick demo of what we can do.");
t->SetPosition(0, 3.5);
t->SetAlignment(TXT_Center);
TextActor *t2 = new TextActor("Console", "(press [A] on the 360 controller or space bar to continue)");
t2->SetPosition(0, 2);
t2->SetAlignment(TXT_Center);
theWorld.Add(t);
theWorld.Add(t2);
//Demo housekeeping below this point.
#pragma region Demo housekeeping
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenStart.cpp");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t);
_objects.push_back(t2);
#pragma endregion
}
开发者ID:FlorianDeconinck,项目名称:angel2d,代码行数:24,代码来源:DemoScreenStart.cpp
示例18: while
void DemoScreenLevelFile::Start()
{
//Loads the file from Config\ActorDef\level_demo.lua
// Level files automatically add their actors to the world.
theWorld.LoadLevel("level_demo");
//Since the Actors were just added directly to the world,
// we don't have handles to them. The level definition
// gave them the tag "spawned," so we can get them that way.
ActorSet spawnedActors = theTagList.GetObjectsTagged("spawned");
ActorSet::iterator it = spawnedActors.begin();
while (it != spawnedActors.end())
{
//Can check Individual actors for tags as well.
if ((*it)->IsTagged("left-tilted"))
{
(*it)->SetRotation(25.0f);
}
else if ((*it)->IsTagged("right-tilted"))
{
(*it)->SetRotation(-25.0f);
}
//Applying tags
(*it)->Tag("rotated");
//Removing tags
(*it)->Untag("spawned");
it++;
}
//Demo housekeeping below this point.
#pragma region Demo housekeeping
t = new TextActor("Console", "These Actors were placed and tagged (\"left-tilted\"");
t->SetPosition(0, 5.5);
t->SetAlignment(TXT_Center);
theWorld.Add(t);
t2 = new TextActor("Console", "and \"right-tilted\") using a level definition file.");
t2->SetPosition(0, 4.5);
t2->SetAlignment(TXT_Center);
theWorld.Add(t2);
t3 = new TextActor("Console", "Then their rotations were set based on those tags.");
t3->SetPosition(0, -4.5);
t3->SetAlignment(TXT_Center);
theWorld.Add(t3);
TextActor *fileLoc = new TextActor("ConsoleSmall", "DemoScreenLevelFile.cpp, level_demo.lua");
fileLoc->SetPosition(MathUtil::ScreenToWorld(5, 763));
fileLoc->SetColor(.3f, .3f, .3f);
theWorld.Add(fileLoc);
_objects.push_back(fileLoc);
_objects.push_back(t);
_objects.push_back(t2);
_objects.push_back(t3);
it = spawnedActors.begin();
while (it != spawnedActors.end())
{
_objects.push_back(*it);
it++;
}
#pragma endregion
}
开发者ID:FlorianDeconinck,项目名称:angel2d,代码行数:64,代码来源:DemoScreenLevelFile.cpp
示例19: TiXmlDeclaration
// save map actors into memory
void MapInfoXmlWriter::SaveActors(const std::string &Filename, std::map<long, Actor *> * vec)
{
TiXmlDocument doc;
TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "UTF8", "" );
doc.LinkEndChild( decl );
TiXmlElement * root = new TiXmlElement("actors");
doc.LinkEndChild( root );
std::map<long, Actor *>::const_iterator it = vec->begin();
std::map<long, Actor *>::const_iterator end = vec->end();
for(; it != end; ++it)
{
TiXmlElement * act = new TiXmlElement( "actor" );
root->LinkEndChild(act);
act->SetAttribute("id", it->second->GetId());
act->SetAttribute("type", it->second->GetType());
act->SetDoubleAttribute("posX", it->second->GetPosX());
act->SetDoubleAttribute("posY", it->second->GetPosY());
act->SetDoubleAttribute("posZ", it->second->GetPosZ());
act->SetDoubleAttribute("sizeX", it->second->GetSizeX());
act->SetDoubleAttribute("sizeY", it->second->GetSizeY());
act->SetDoubleAttribute("sizeZ", it->second->GetSizeZ());
act->SetDoubleAttribute("offsetsizeY", it->second->GetOffsetSizeY());
act->SetDoubleAttribute("rotation", it->second->GetRotation());
act->SetAttribute("passable", it->second->IsPassable());
act->SetAttribute("depthmask", it->second->IsDepthMask());
act->SetAttribute("movable", it->second->IsMovable());
act->SetAttribute("outputsignal", it->second->GetSignal());
act->SetAttribute("attachedsound", it->second->GetAttachedSound());
act->SetAttribute("collidable", it->second->GetCollidable());
act->SetAttribute("actif", it->second->GetActif());
act->SetAttribute("allowfreemove", it->second->GetAllowFreeMove());
{
std::vector<long> vect = it->second->GetTargets();
std::stringstream str;
if(vect.size() > 0)
str<<vect[0];
for(size_t i=1; i<vect.size(); ++i)
str<<","<<vect[i];
act->SetAttribute("signaltargets", str.str());
}
if(it->second->GetRenderer() != NULL)
{
act->SetAttribute("renderertype", it->second->GetRendererType());
std::vector<long> vect = it->second->GetRendererTarget();
std::stringstream str;
if(vect.size() > 0)
str<<vect[0];
for(size_t i=1; i<vect.size(); ++i)
str<<","<<vect[i];
act->SetAttribute("renderertarget", str.str());
}
switch(it->second->GetType())
{
case 1: //text actor class
{
{
TextActor * tmpa = static_cast<TextActor *>(it->second);
act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
act->SetAttribute("textid", tmpa->GetTextId());
act->SetAttribute("activationtype", tmpa->GetActivationType());
}
}
break;
case 2: //ladder actor class
{
{
LadderActor * tmpa = static_cast<LadderActor *>(it->second);
act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
act->SetDoubleAttribute("deltaX", tmpa->GetDX());
act->SetDoubleAttribute("deltaY", tmpa->GetDY());
act->SetDoubleAttribute("deltaZ", tmpa->GetDZ());
act->SetAttribute("direction", tmpa->GetDir());
act->SetAttribute("activationtype", tmpa->GetActivationType());
}
}
break;
case 3: //exit actor class
{
{
ExitActor * tmpa = static_cast<ExitActor *>(it->second);
act->SetDoubleAttribute("activationdistance", tmpa->GetActivationDistance());
act->SetDoubleAttribute("deltaX", tmpa->GetDX());
act->SetDoubleAttribute("deltaY", tmpa->GetDY());
act->SetDoubleAttribute("deltaZ", tmpa->GetDZ());
act->SetAttribute("direction", tmpa->GetDir());
act->SetAttribute("activationtype", tmpa->GetActivationType());
}
//.........这里部分代码省略.........
开发者ID:leloulight,项目名称:lbanet,代码行数:101,代码来源:MapInfoXmlWriter.cpp
注:本文中的TextActor类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论