瀏覽代碼

Merge branch 'pr_convenience_members' of https://github.com/zmeyc/oxygine-framework

dmuratshin 10 年之前
父節點
當前提交
a0923eec81
共有 4 個文件被更改,包括 13 次插入3 次删除
  1. 5 3
      oxygine/src/Actor.h
  2. 2 0
      oxygine/src/core/file.h
  3. 3 0
      oxygine/src/math/Rect.h
  4. 3 0
      oxygine/src/math/vector2.h

+ 5 - 3
oxygine/src/Actor.h

@@ -130,9 +130,11 @@ namespace oxygine
         Vector2             getSize() const {return _size;}
         /**Returns Size*Scale*/
         Vector2             getScaledSize() const { return _size.mult(_scale); }
-        float               getWidth() const {return getSize().x;}
-        float               getHeight() const {return getSize().y;}
-        unsigned char       getAlpha() const;
+        float               getWidth() const {return _size.x;}
+        float               getScaledWidth() const {return _size.x * _scale.x;}
+        float               getHeight() const {return _size.y;}
+        float               getScaledHeight() const {return _size.y * _scale.y;}
+        unsigned char       getAlpha() const {return _alpha;}
         const spClock&      getClock() const;
         virtual RectF       getDestRect() const;
         /**returns touch id if actor is pressed down*/

+ 2 - 0
oxygine/src/core/file.h

@@ -41,6 +41,8 @@ namespace oxygine
 
             const void* getData() const {if (data.empty()) return 0; return &data[0];}
             unsigned int getSize() const {return (unsigned int)data.size();}
+			
+			std::string getString() const {return std::string((char *)&data[0], size());}
 
             typedef std::vector<uchar> buff;
             buff data;

+ 3 - 0
oxygine/src/math/Rect.h

@@ -96,8 +96,11 @@ namespace oxygine
         T getRight() const {return pos.x + size.x;}
         T getBottom() const {return pos.y + size.y;}
 
+		void set(T x, T y, T w, T h) {pos.x = x; pos.y = y; size.x = w; size.y = h;}
         void setPosition(const point2& pos_) {pos = pos_;}
+		void setPosition(T x, T y) {pos.x = x; pos.y = y;}
         void setSize(const point2& size_) {size = size_;}
+		void setSize(T x, T y) {size.x = x; size.y = y;}
         void setX(T v) {pos.x = v;}
         void setY(T v) {pos.y = v;}
 

+ 3 - 0
oxygine/src/math/vector2.h

@@ -22,6 +22,9 @@ namespace oxygine
         VectorT2 operator - (const VectorT2&) const;
         VectorT2 operator - () const;
 
+		void set(T x_, T y_) {x = x_; y = y_;}
+		void setZero() {x = 0; y = 0;}
+		
         template <class R>
         VectorT2 operator * (R s) const {VectorT2 r(*this); r.x = type(r.x * s); r.y = type(r.y * s); return r;}
         template <class R>