Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GameObjectPhysics::GameObjectPhysics(
- State* state_,
- CSCore::Vector2 sprite_dimensions_,
- CSCore::Vector2 physics_dimensions_,
- CSCore::Vector2 position_,
- CSCore::Vector2 physics_offset_,
- std::string texture_name_,
- std::string sprite_name_,
- int body_type_) :
- state(state_),
- sprite_dimensions(sprite_dimensions_),
- physics_offset(physics_offset_),
- flagged_for_deletion(false)
- {
- CSRendering::SpriteComponentSPtr sprite_component;
- if (body_type_ != BodyType::KINEMATIC)
- {
- //load the texture and texture atlas.
- CSCore::ResourcePool* resourcePool =
- CSCore::Application::Get()->GetResourcePool();
- CSRendering::TextureCSPtr texture =
- resourcePool->LoadResource<CSRendering::Texture>(CSCore::StorageLocation::k_package, texture_name_ + ".csimage");
- CSRendering::TextureAtlasCSPtr textureAtlas =
- resourcePool->LoadResource<CSRendering::TextureAtlas>(CSCore::StorageLocation::k_package, texture_name_ + ".csatlas");
- //create the material
- CSRendering::MaterialFactory* materialFactory =
- CSCore::Application::Get()->GetSystem<CSRendering::MaterialFactory>();
- CSRendering::MaterialSPtr material =
- materialFactory->CreateSprite(texture_name_ + "_material_" + UniqueIntGenerator::getUniqueString(), texture);
- material->SetTransparencyEnabled(true);
- //Create the sprite component
- sprite_component =
- state->getRenderComponentFactory()->CreateSpriteComponent(
- sprite_dimensions,
- textureAtlas,
- sprite_name_,
- material,
- CSRendering::SpriteComponent::SizePolicy::k_none);
- }
- //create the sprite entity and add the sprite component
- entity = CSCore::Entity::Create();
- if (body_type_ != BodyType::KINEMATIC)
- entity->AddComponent(sprite_component);
- //add the sprite to the scene
- state->GetScene()->Add(entity);
- // initialise the body
- ...
- syncPositioning();
- state->addGO(this);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement