Просмотр исходного кода

SceneSprite, PhysicsScene2D fix and some backwards compatibility typedefs

Ivan Safrin 12 лет назад
Родитель
Сommit
d3f13be1af

+ 5 - 0
Core/Contents/Include/PolyEntity.h

@@ -72,8 +72,13 @@ namespace Polycode {
 	class _PolyExport Entity : public EventDispatcher {
 		public:
 			Entity();
+			
+			Entity(Number width, Number height, Number depth = 0.01);	
+			
 			virtual ~Entity();
 
+
+			void initEntity();
 			/**
 			* Main render method. Override this to do your own drawing.
 			*/

+ 1 - 0
Core/Contents/Source/PolyCamera.cpp

@@ -45,6 +45,7 @@ Camera::Camera(Scene *parentScene) : Entity() {
 	frustumCulling = true;
 	nearClipPlane = 1.0;
 	farClipPlane = 1000.0;
+	topLeftOrtho = false;
 }
 
 Camera::~Camera() {	

+ 11 - 0
Core/Contents/Source/PolyEntity.cpp

@@ -33,6 +33,17 @@ Rotation::Rotation() {
 }
 
 Entity::Entity() : EventDispatcher() {
+	initEntity();
+}
+
+Entity::Entity(Number width, Number height, Number depth) : EventDispatcher() {
+	initEntity();
+	bBox.x = width;
+	bBox.y = height;
+	bBox.z = depth;		
+}
+
+void Entity::initEntity() {
 	userData = NULL;
 	scale.set(1,1,1);
 	renderer = NULL;

+ 1 - 0
Core/Contents/Source/PolyScene.cpp

@@ -70,6 +70,7 @@ void Scene::initScene(int sceneType, bool virtualScene) {
 	
 	switch(sceneType) {
 		case SCENE_2D:
+			printf("WHAT\n");
 			defaultCamera->setClippingPlanes(-100.0, 100.0);
 			defaultCamera->setOrthoMode(true, CoreServices::getInstance()->getCore()->getXRes(),CoreServices::getInstance()->getCore()->getYRes());	
 		break;

+ 1 - 0
Core/Contents/Source/PolySceneSprite.cpp

@@ -174,6 +174,7 @@ SceneSprite::SceneSprite(const String& fileName, Number spriteWidth, Number spri
 	currentFrame = 0;
 	currentAnimation = NULL;	
 	paused = false;
+	setPrimitiveOptions(ScenePrimitive::TYPE_VPLANE, spriteWidth, spriteHeight);	
 }
 
 SceneSprite::~SceneSprite() {

+ 3 - 0
Modules/Contents/2DPhysics/Include/PolyPhysicsScreen.h

@@ -420,4 +420,7 @@ protected:
 };
 
 
+	typedef PhysicsScene2D PhysicsScreen;
+	typedef PhysicsScene2DEvent PhysicsScreenEvent;
+
 }

+ 2 - 0
Modules/Contents/2DPhysics/Include/PolyPhysicsScreenEntity.h

@@ -150,5 +150,7 @@ namespace Polycode {
 			Number worldScale;        
 			Entity *entity;
 	};
+	
+	typedef PhysicsScene2DEntity PhysicsScreenEntity;
 
 }

+ 4 - 4
Modules/Contents/2DPhysics/Source/PolyPhysicsScreen.cpp

@@ -195,12 +195,12 @@ bool PhysicsScene2D::testEntityCollision(Entity *ent1, Entity *ent2) {
 	return false;
 }
 
-PhysicsScene2D::PhysicsScene2D() : Scene() {
-	init(10.0f, 1.0f/60.0f,10,10,Vector2(0.0f, 10.0f));
+PhysicsScene2D::PhysicsScene2D() : Scene(Scene::SCENE_2D) {
+	init(10.0f, 1.0f/60.0f,10,10,Vector2(0.0f, -10.0f));
 }
 
-PhysicsScene2D::PhysicsScene2D(Number worldScale, Number freq, int velIterations, int posIterations): Scene() {
-	init(worldScale, 1.0f/freq,velIterations, posIterations, Vector2(0.0f, 10.0f));	
+PhysicsScene2D::PhysicsScene2D(Number worldScale, Number freq, int velIterations, int posIterations): Scene(Scene::SCENE_2D) {
+	init(worldScale, 1.0f/freq,velIterations, posIterations, Vector2(0.0f, -10.0f));	
 }
 
 void PhysicsScene2D::init(Number worldScale, Number physicsTimeStep, int velIterations, int posIterations, Vector2 physicsGravity) {