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
CzModifierExt.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_MODIFIER_EXT_H_)
00015 #define _CZ_MODIFIER_EXT_H_
00016 
00017 #include "CzUtil.h"
00018 #include "CzModifier.h"
00019 #include "CzActor.h"
00020 
00021 //
00022 //
00023 //  CzModFollowHeading - Modifier that calculates actors velocity based on heading and speed
00024 //
00025 //  Parameter1 - Heading in degrees (float)
00026 //  Parameter2 - Speed (float)
00027 //
00028 //
00029 class CzModFollowHeading : public IzModifier
00030 {
00031     // Properties
00032 protected:
00033     float       Heading;                // Direction
00034     float       Speed;                  // Speed of travel
00035 
00036 public:
00037     void        setHeading(float angle)             { Heading = angle; }
00038     float       getHeading() const                  { return Heading; }
00039     void        setSpeed(float speed)               { Speed = speed; }
00040     float       getSpeed() const                    { return Speed; }
00041     // Properties End
00042 
00043 public:
00044     void InitModifier(IzXomlResource* target)
00045     {
00046         Heading = Params[0].getAsFloat();
00047         Speed = Params[1].getAsFloat();
00048     }
00049     void ReleaseModifier(IzXomlResource* target)
00050     {
00051     }
00052     bool UpdateModifier(IzXomlResource* target, float dt)
00053     {
00054         CzActor* actor = (CzActor*)target;
00055         float angle = (Heading * 3.1415927f) / 180.0f;
00056 
00057         actor->setVelocity(cosf(Heading) * Speed, sinf(Heading) * Speed);
00058 
00059         return true;
00060     }
00061 };
00062 class CzModFollowHeadingCreator : public IzModifierCreator
00063 {
00064 public:
00065     CzModFollowHeadingCreator()
00066     {
00067         setClassName("iw_followheading");
00068     }
00069     IzModifier* CreateInstance() { return new CzModFollowHeading(); }
00070 };
00071 
00072 //
00073 //
00074 //  CzModCollisionNotify - Modifier that adds Box2D collision notifications
00075 //
00076 //  Parameter1 - Collision mask, any actors that pass the mask are potential colliders
00077 //
00078 //
00079 class CzModCollisionNotify : public IzModifier
00080 {
00081     // Properties
00082 protected:
00083     int         CollisionMask;                  // Colision  mask, any actors that pass the mask are potential colliders
00084 
00085 public:
00086     void        setCollisionMask(int mask)          { CollisionMask = mask; }
00087     int         getCollisionMask() const            { return CollisionMask; }
00088     // Properties End
00089 
00090 public:
00091     void InitModifier(IzXomlResource* target)
00092     {
00093         if (Params[0].isEmpty())
00094             CollisionMask = 0;
00095         else
00096             CollisionMask = Params[0].getAsInt();
00097     }
00098     void ReleaseModifier(IzXomlResource* target)
00099     {
00100     }
00101     bool UpdateModifier(IzXomlResource* target, float dt);
00102 };
00103 class CzModCollisionNotifyCreator : public IzModifierCreator
00104 {
00105 public:
00106     CzModCollisionNotifyCreator()
00107     {
00108         setClassName("iw_notifycollision");
00109     }
00110     IzModifier* CreateInstance() { return new CzModCollisionNotify(); }
00111 };
00112 
00113 //
00114 //
00115 //  CzModScript - Modifier that calls a script to modify the object
00116 //
00117 //  Parameter1 - Script function name, any actors that pass the mask are potential colliders
00118 //
00119 //
00120 class CzModScript : public IzModifier
00121 {
00122     // Properties
00123 protected:
00124     int         CollisionMask;                  // Colision  mask, any actors that pass the mask are potential colliders
00125 
00126 public:
00127     void        setCollisionMask(int mask)          { CollisionMask = mask; }
00128     int         getCollisionMask() const            { return CollisionMask; }
00129     // Properties End
00130 
00131 public:
00132     void InitModifier(IzXomlResource* target)
00133     {
00134     }
00135     void ReleaseModifier(IzXomlResource* target)
00136     {
00137     }
00138     bool UpdateModifier(IzXomlResource* target, float dt);
00139 };
00140 class CzModScriptCreator : public IzModifierCreator
00141 {
00142 public:
00143     CzModScriptCreator()
00144     {
00145         setClassName("iw_callscript");
00146     }
00147     IzModifier* CreateInstance() { return new CzModScript(); }
00148 };
00149 
00150 
00151 
00152 
00153 #endif  // _CZ_MODIFIER_EXT_H_