AppEasy Core SDK  1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
CzBox2dMaterial.h
Go to the documentation of this file.
00001 // 
00002 //
00003 // AppEasy SDK - Cross Platform Multi-purpose Game and App Engine
00004 //
00005 // Developed by Matthew Hopwood of Pocketeers Limited - www.pocketeers.co.uk
00006 //
00007 // For updates, tutorials and more details check out www.appeasymobile.com
00008 //
00009 // This code is provided free of charge and without any warranty whatsoever. You must ensure that this whole notice is present in all files and derivatives, so the reader knows its origin.
00010 // If you use this SDK in your product then please ensure that you credit AppEasy's usage appropriately. Please see www.appeasymobile.com for licensing details and support
00011 //
00012 //
00013 
00014 #if !defined(_CZ_BOX2D_MATERIAL_H_)
00015 #define _CZ_BOX2D_MATERIAL_H_
00016 
00017 #include "CzUtil.h"
00018 #include "CzString.h"
00019 #include "CzXoml.h"
00020 #include "CzShapes.h"
00021 #include "CzSlotArray.h"
00022 
00023 #include "Box2D/Box2D.h"
00024 
00025 //
00026 //
00027 //
00028 //
00029 // CzBox2dMaterial - Box2D physics material
00030 //
00031 //
00032 //
00033 //
00034 class CzBox2dMaterial : public IzXomlResource
00035 {
00036 public:
00037 
00038 protected:
00039     // Properties
00040     b2BodyType          BodyType;           // Physical body type
00041     float               Density;            // Density of body
00042     float               Friction;           // Amount of friction to apply
00043     float               Restitution;        // Bounciness of the object
00044     bool                Bullet;             // Is bullet type (is set then object will use continuous colilsion detection (slower)) - only use for very fast moviog objects
00045     bool                FixedRotation;      // Set to true if you do not want an objects raotation to change
00046     float               GravityScale;       // Specific gravity scale
00047 public:
00048     void                setBodyType(b2BodyType type)        { BodyType = type; }
00049     b2BodyType          getBodyType() const                 { return BodyType; }
00050     void                setDensity(float density)           { Density = density; }
00051     float               getDensity() const                  { return Density; }
00052     void                setFriction(float friction)         { Friction = friction; }
00053     float               getFriction() const                 { return Friction; }
00054     void                setRestitution(float restitution)   { Restitution = restitution; }
00055     float               getRestitution() const              { return Restitution; }
00056     void                setBullet(bool bullet)              { Bullet = bullet; }
00057     bool                isBullet() const                    { return Bullet; }
00058     void                setFixedRotation(bool fixed)        { FixedRotation = fixed; }
00059     bool                isFixedRotation() const             { return FixedRotation; }
00060     void                setGravityScale(float scale)        { GravityScale = scale; }
00061     float               getGravityScale() const             { return GravityScale; }
00062     // Properties end
00063 
00064 public:
00065     CzBox2dMaterial() : IzXomlResource(), Density(1.0f), Friction(1.0f), Restitution(0.1f), Bullet(false), FixedRotation(false), GravityScale(1000000.0f)  { setClassType("box2dmaterial"); }
00066     virtual ~CzBox2dMaterial() {}
00067 
00068     // Implementation of IzXomlResource interface
00069     int                 LoadFromXoml(IzXomlResource* parent, bool load_children, CzXmlNode* node);
00070 };
00071 
00072 //
00073 //  CzBox2dMaterialCreator - Creates an instance of a box2d material object
00074 //
00075 class CzBox2dMaterialCreator : public IzXomlClassCreator
00076 {
00077 public:
00078     CzBox2dMaterialCreator()
00079     {
00080         setClassName("box2dmaterial");
00081     }
00082     IzXomlResource* CreateInstance(IzXomlResource* parent)  { return new CzBox2dMaterial(); }
00083 };
00084 
00085 
00086 
00087 #endif // _CZ_BOX2D_MATERIAL_H_