性能优化

This commit is contained in:
Nomango 2018-07-28 20:06:27 +08:00
parent 4a80f2df88
commit 840b554190
50 changed files with 452 additions and 449 deletions

View File

@ -11,12 +11,12 @@ e2d::Animation::Animation(const std::vector<Image*>& frames)
this->add(frames); this->add(frames);
} }
e2d::Animation::Animation(double interval) e2d::Animation::Animation(float interval)
: _interval(interval) : _interval(interval)
{ {
} }
e2d::Animation::Animation(double interval, const std::vector<Image*>& frames) e2d::Animation::Animation(float interval, const std::vector<Image*>& frames)
: _interval(interval) : _interval(interval)
{ {
this->add(frames); this->add(frames);
@ -30,9 +30,9 @@ e2d::Animation::~Animation()
} }
} }
void e2d::Animation::setInterval(double interval) void e2d::Animation::setInterval(float interval)
{ {
_interval = std::max(interval, 0.0); _interval = std::max(interval, 0.f);
} }
void e2d::Animation::add(Image * frame) void e2d::Animation::add(Image * frame)
@ -52,7 +52,7 @@ void e2d::Animation::add(const std::vector<Image*>& frames)
} }
} }
double e2d::Animation::getInterval() const float e2d::Animation::getInterval() const
{ {
return _interval; return _interval;
} }

View File

@ -1,8 +1,8 @@
#include "..\e2daction.h" #include "..\e2daction.h"
e2d::Delay::Delay(double duration) e2d::Delay::Delay(float duration)
: _delta(0) : _delta(0)
, _delay(std::max(duration, 0.0)) , _delay(std::max(duration, 0.f))
{ {
} }

View File

@ -1,8 +1,8 @@
#include "..\e2daction.h" #include "..\e2daction.h"
e2d::FiniteTimeAction::FiniteTimeAction(double duration) e2d::FiniteTimeAction::FiniteTimeAction(float duration)
: _delta(0) : _delta(0)
, _duration(std::max(duration, 0.0)) , _duration(std::max(duration, 0.f))
{ {
} }
@ -28,7 +28,7 @@ void e2d::FiniteTimeAction::_update()
} }
else else
{ {
_delta = std::min((Game::getInstance()->getTotalDuration().seconds() - _last) / _duration, 1.0); _delta = std::min((Game::getInstance()->getTotalDuration().seconds() - _last) / _duration, 1.f);
if (_delta >= 1) if (_delta >= 1)
{ {

View File

@ -1,7 +1,7 @@
#include "..\e2daction.h" #include "..\e2daction.h"
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::JumpBy::JumpBy(double duration, const Vector2 & vec, double height, int jumps) e2d::JumpBy::JumpBy(float duration, const Vector2 & vec, float height, int jumps)
: FiniteTimeAction(duration) : FiniteTimeAction(duration)
, _deltaPos(vec) , _deltaPos(vec)
, _height(height) , _height(height)
@ -35,9 +35,9 @@ void e2d::JumpBy::_update()
if (_target) if (_target)
{ {
double frac = fmod(_delta * _jumps, 1.0); float frac = fmod(_delta * _jumps, 1.f);
double x = _deltaPos.x * _delta; float x = _deltaPos.x * _delta;
double y = _height * 4 * frac * (1 - frac); float y = _height * 4 * frac * (1 - frac);
y += _deltaPos.y * _delta; y += _deltaPos.y * _delta;
Point currentPos = _target->getPos(); Point currentPos = _target->getPos();

View File

@ -1,7 +1,7 @@
#include "..\e2daction.h" #include "..\e2daction.h"
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::JumpTo::JumpTo(double duration, const Point & pos, double height, int jumps) e2d::JumpTo::JumpTo(float duration, const Point & pos, float height, int jumps)
: JumpBy(duration, Point(), height, jumps) : JumpBy(duration, Point(), height, jumps)
, _endPos(pos) , _endPos(pos)
{ {

View File

@ -2,7 +2,7 @@
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::MoveBy::MoveBy(double duration, Vector2 vector) e2d::MoveBy::MoveBy(float duration, Vector2 vector)
: FiniteTimeAction(duration) : FiniteTimeAction(duration)
{ {
_deltaPos = vector; _deltaPos = vector;

View File

@ -1,7 +1,7 @@
#include "..\e2daction.h" #include "..\e2daction.h"
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::MoveTo::MoveTo(double duration, Point pos) e2d::MoveTo::MoveTo(float duration, Point pos)
: MoveBy(duration, Vector2()) : MoveBy(duration, Vector2())
{ {
_endPos = pos; _endPos = pos;

View File

@ -2,7 +2,7 @@
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::OpacityBy::OpacityBy(double duration, double opacity) e2d::OpacityBy::OpacityBy(float duration, float opacity)
: FiniteTimeAction(duration) : FiniteTimeAction(duration)
{ {
_deltaVal = opacity; _deltaVal = opacity;

View File

@ -2,7 +2,7 @@
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::OpacityTo::OpacityTo(double duration, double opacity) e2d::OpacityTo::OpacityTo(float duration, float opacity)
: OpacityBy(duration, 0) : OpacityBy(duration, 0)
{ {
_endVal = opacity; _endVal = opacity;

View File

@ -2,7 +2,7 @@
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::RotateBy::RotateBy(double duration, double rotation) e2d::RotateBy::RotateBy(float duration, float rotation)
: FiniteTimeAction(duration) : FiniteTimeAction(duration)
{ {
_deltaVal = rotation; _deltaVal = rotation;

View File

@ -2,7 +2,7 @@
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::RotateTo::RotateTo(double duration, double rotation) e2d::RotateTo::RotateTo(float duration, float rotation)
: RotateBy(duration, 0) : RotateBy(duration, 0)
{ {
_endVal = rotation; _endVal = rotation;

View File

@ -2,14 +2,14 @@
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::ScaleBy::ScaleBy(double duration, double scale) e2d::ScaleBy::ScaleBy(float duration, float scale)
: FiniteTimeAction(duration) : FiniteTimeAction(duration)
{ {
_deltaX = scale; _deltaX = scale;
_deltaY = scale; _deltaY = scale;
} }
e2d::ScaleBy::ScaleBy(double duration, double scaleX, double scaleY) e2d::ScaleBy::ScaleBy(float duration, float scaleX, float scaleY)
: FiniteTimeAction(duration) : FiniteTimeAction(duration)
{ {
_deltaX = scaleX; _deltaX = scaleX;

View File

@ -1,14 +1,14 @@
#include "..\e2daction.h" #include "..\e2daction.h"
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::ScaleTo::ScaleTo(double duration, double scale) e2d::ScaleTo::ScaleTo(float duration, float scale)
: ScaleBy(duration, 0, 0) : ScaleBy(duration, 0, 0)
{ {
_endScaleX = scale; _endScaleX = scale;
_endScaleY = scale; _endScaleY = scale;
} }
e2d::ScaleTo::ScaleTo(double duration, double scaleX, double scaleY) e2d::ScaleTo::ScaleTo(float duration, float scaleX, float scaleY)
: ScaleBy(duration, 0, 0) : ScaleBy(duration, 0, 0)
{ {
_endScaleX = scaleX; _endScaleX = scaleX;

View File

@ -107,11 +107,7 @@ void e2d::GC::safeRelease(Ref* ref)
if (ref) if (ref)
{ {
auto iter = _pool.find(ref); ref->release();
if (iter != _pool.end()) _notifyed = true;
{
(*iter)->release();
_notifyed = true;
}
} }
} }

View File

@ -184,12 +184,12 @@ bool e2d::Input::isRelease(MouseCode code)
return false; return false;
} }
double e2d::Input::getMouseX() float e2d::Input::getMouseX()
{ {
return getMousePos().x; return getMousePos().x;
} }
double e2d::Input::getMouseY() float e2d::Input::getMouseY()
{ {
return getMousePos().y; return getMousePos().y;
} }
@ -203,20 +203,20 @@ e2d::Point e2d::Input::getMousePos()
ScreenToClient(hWnd, &mousePos); ScreenToClient(hWnd, &mousePos);
UINT ret = ::GetDpiForWindow(hWnd); UINT ret = ::GetDpiForWindow(hWnd);
return Point(mousePos.x * 96.0 / ret, mousePos.y * 96.0 / ret); return Point(mousePos.x * 96.f / ret, mousePos.y * 96.f / ret);
} }
double e2d::Input::getMouseDeltaX() float e2d::Input::getMouseDeltaX()
{ {
return (double)_mouseState.lX; return (float)_mouseState.lX;
} }
double e2d::Input::getMouseDeltaY() float e2d::Input::getMouseDeltaY()
{ {
return (double)_mouseState.lY; return (float)_mouseState.lY;
} }
double e2d::Input::getMouseDeltaZ() float e2d::Input::getMouseDeltaZ()
{ {
return (double)_mouseState.lZ; return (float)_mouseState.lZ;
} }

View File

@ -181,12 +181,12 @@ void e2d::Window::poll()
} }
} }
double e2d::Window::getWidth() float e2d::Window::getWidth()
{ {
return _size.width; return _size.width;
} }
double e2d::Window::getHeight() float e2d::Window::getHeight()
{ {
return _size.height; return _size.height;
} }
@ -216,7 +216,7 @@ HWND e2d::Window::getHWnd()
void e2d::Window::setSize(int width, int height) void e2d::Window::setSize(int width, int height)
{ {
this->_size = Size(width, height); this->_size = Size(static_cast<float>(width), static_cast<float>(height));
if (_hWnd) if (_hWnd)
{ {
float dpiScaleX = 0.f, dpiScaleY = 0.f; float dpiScaleX = 0.f, dpiScaleY = 0.f;
@ -225,7 +225,7 @@ void e2d::Window::setSize(int width, int height)
width = static_cast<int>(ceil(width * dpiScaleX / 96.f)); width = static_cast<int>(ceil(width * dpiScaleX / 96.f));
height = static_cast<int>(ceil(height * dpiScaleY / 96.f)); height = static_cast<int>(ceil(height * dpiScaleY / 96.f));
// 计算窗口大小 // 计算窗口大小
DWORD dwStyle = WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX &~WS_THICKFRAME; DWORD dwStyle = WS_OVERLAPPEDWINDOW & ~WS_MAXIMIZEBOX & ~WS_THICKFRAME;
RECT wr = { 0, 0, static_cast<LONG>(width), static_cast<LONG>(height) }; RECT wr = { 0, 0, static_cast<LONG>(width), static_cast<LONG>(height) };
::AdjustWindowRectEx(&wr, dwStyle, FALSE, NULL); ::AdjustWindowRectEx(&wr, dwStyle, FALSE, NULL);
// 获取新的宽高 // 获取新的宽高
@ -435,7 +435,7 @@ LRESULT e2d::Window::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPar
if (wParam == SIZE_RESTORED) if (wParam == SIZE_RESTORED)
{ {
UINT dpi = ::GetDpiForWindow(hWnd); UINT dpi = ::GetDpiForWindow(hWnd);
_instance->_size = Size(width * 96.0 / dpi, height * 96.0 / dpi); _instance->_size = Size(width * 96.f / dpi, height * 96.f / dpi);
} }
// 如果程序接收到一个 WM_SIZE 消息,这个方法将调整渲染 // 如果程序接收到一个 WM_SIZE 消息,这个方法将调整渲染

View File

@ -4,7 +4,7 @@
e2d::Collider::Collider(Node * parent) e2d::Collider::Collider(Node * parent)
: _visible(true) : _visible(true)
, _color(Color::Blue, 0.6) , _color(Color::Blue, 0.6f)
, _parentNode(parent) , _parentNode(parent)
, _geometry(nullptr) , _geometry(nullptr)
, _enabled(true) , _enabled(true)
@ -16,7 +16,6 @@ e2d::Collider::Collider(Node * parent)
e2d::Collider::~Collider() e2d::Collider::~Collider()
{ {
SafeRelease(_geometry); SafeRelease(_geometry);
} }
e2d::Color e2d::Collider::getColor() const e2d::Color e2d::Collider::getColor() const
@ -139,11 +138,7 @@ void e2d::Collider::recreate()
{ {
ID2D1RectangleGeometry* rectangle = nullptr; ID2D1RectangleGeometry* rectangle = nullptr;
Renderer::getFactory()->CreateRectangleGeometry( Renderer::getFactory()->CreateRectangleGeometry(
D2D1::RectF( D2D1::RectF(0, 0, _parentNode->getRealWidth(), _parentNode->getRealHeight()),
0,
0,
float(_parentNode->getRealWidth()),
float(_parentNode->getRealHeight())),
&rectangle &rectangle
); );
_geometry = rectangle; _geometry = rectangle;
@ -152,17 +147,17 @@ void e2d::Collider::recreate()
case Shape::Circle: case Shape::Circle:
{ {
double minSide = std::min(_parentNode->getRealWidth(), _parentNode->getRealHeight()); float minSide = std::min(_parentNode->getRealWidth(), _parentNode->getRealHeight());
ID2D1EllipseGeometry* circle = nullptr; ID2D1EllipseGeometry* circle = nullptr;
Renderer::getFactory()->CreateEllipseGeometry( Renderer::getFactory()->CreateEllipseGeometry(
D2D1::Ellipse( D2D1::Ellipse(
D2D1::Point2F( D2D1::Point2F(
float(_parentNode->getRealWidth() / 2), _parentNode->getRealWidth() / 2,
float(_parentNode->getRealHeight() / 2) _parentNode->getRealHeight() / 2
), ),
float(minSide / 2), minSide / 2,
float(minSide / 2) minSide / 2
), ),
&circle &circle
); );
@ -172,8 +167,8 @@ void e2d::Collider::recreate()
case Shape::Ellipse: case Shape::Ellipse:
{ {
float halfWidth = float(_parentNode->getWidth() / 2), float halfWidth = _parentNode->getWidth() / 2,
halfHeight = float(_parentNode->getHeight() / 2); halfHeight = _parentNode->getHeight() / 2;
ID2D1EllipseGeometry* ellipse = nullptr; ID2D1EllipseGeometry* ellipse = nullptr;
Renderer::getFactory()->CreateEllipseGeometry( Renderer::getFactory()->CreateEllipseGeometry(

View File

@ -12,23 +12,23 @@ e2d::Color::Color()
: r(0) : r(0)
, g(0) , g(0)
, b(0) , b(0)
, a(1) , a(1.f)
{ {
} }
e2d::Color::Color(double r, double g, double b) e2d::Color::Color(float r, float g, float b)
: r(float(r)) : r(r)
, g(float(g)) , g(g)
, b(float(b)) , b(b)
, a(float(1)) , a(1.f)
{ {
} }
e2d::Color::Color(double r, double g, double b, double alpha) e2d::Color::Color(float r, float g, float b, float alpha)
: r(float(r)) : r(r)
, g(float(g)) , g(g)
, b(float(b)) , b(b)
, a(float(alpha)) , a(alpha)
{ {
} }
@ -37,17 +37,17 @@ e2d::Color::Color(UINT rgb)
_init(rgb, 1); _init(rgb, 1);
} }
e2d::Color::Color(UINT rgb, double alpha) e2d::Color::Color(UINT rgb, float alpha)
{ {
_init(rgb, alpha); _init(rgb, alpha);
} }
void e2d::Color::_init(UINT rgb, double alpha) void e2d::Color::_init(UINT rgb, float alpha)
{ {
r = float((rgb & sc_redMask) >> sc_redShift) / 255.f; r = ((rgb & sc_redMask) >> sc_redShift) / 255.f;
g = float((rgb & sc_greenMask) >> sc_greenShift) / 255.f; g = ((rgb & sc_greenMask) >> sc_greenShift) / 255.f;
b = float((rgb & sc_blueMask) >> sc_blueShift) / 255.f; b = ((rgb & sc_blueMask) >> sc_blueShift) / 255.f;
a = float(alpha); a = alpha;
} }
D2D1_COLOR_F e2d::Color::toD2DColorF() const D2D1_COLOR_F e2d::Color::toD2DColorF() const

View File

@ -57,8 +57,8 @@ void e2d::Config::setCollisionEnabled(bool enabled)
void e2d::Config::setNodeDefaultPivot(Point pivot) void e2d::Config::setNodeDefaultPivot(Point pivot)
{ {
_defaultNodePivot = Point( _defaultNodePivot = Point(
std::min(std::max(pivot.x, 0.0), 1.0), std::min(std::max(pivot.x, 0.f), 1.f),
std::min(std::max(pivot.y, 0.0), 1.0) std::min(std::max(pivot.y, 0.f), 1.f)
); );
} }

View File

@ -22,9 +22,9 @@ int e2d::Duration::milliseconds() const
return static_cast<int>(_ms.count()); return static_cast<int>(_ms.count());
} }
double e2d::Duration::seconds() const float e2d::Duration::seconds() const
{ {
return _ms.count() / 1000.0; return _ms.count() / 1000.f;
} }
bool e2d::Duration::operator==(const Duration & other) const bool e2d::Duration::operator==(const Duration & other) const

View File

@ -8,7 +8,7 @@ e2d::Font::Font()
{ {
} }
e2d::Font::Font(const String & family, double size, UINT weight, bool italic) e2d::Font::Font(const String & family, float size, UINT weight, bool italic)
: family(family) : family(family)
, size(size) , size(size)
, weight(weight) , weight(weight)

View File

@ -73,19 +73,19 @@ void e2d::Image::crop(const Rect& cropRect)
{ {
if (_bitmap) if (_bitmap)
{ {
_cropRect.origin.x = std::min(std::max(cropRect.origin.x, 0.0), this->getSourceWidth()); _cropRect.origin.x = std::min(std::max(cropRect.origin.x, 0.f), this->getSourceWidth());
_cropRect.origin.y = std::min(std::max(cropRect.origin.y, 0.0), this->getSourceHeight()); _cropRect.origin.y = std::min(std::max(cropRect.origin.y, 0.f), this->getSourceHeight());
_cropRect.size.width = std::min(std::max(cropRect.size.width, 0.0), this->getSourceWidth() - cropRect.origin.x); _cropRect.size.width = std::min(std::max(cropRect.size.width, 0.f), this->getSourceWidth() - cropRect.origin.x);
_cropRect.size.height = std::min(std::max(cropRect.size.height, 0.0), this->getSourceHeight() - cropRect.origin.y); _cropRect.size.height = std::min(std::max(cropRect.size.height, 0.f), this->getSourceHeight() - cropRect.origin.y);
} }
} }
double e2d::Image::getWidth() const float e2d::Image::getWidth() const
{ {
return _cropRect.size.width; return _cropRect.size.width;
} }
double e2d::Image::getHeight() const float e2d::Image::getHeight() const
{ {
return _cropRect.size.height; return _cropRect.size.height;
} }
@ -95,7 +95,7 @@ e2d::Size e2d::Image::getSize() const
return _cropRect.size; return _cropRect.size;
} }
double e2d::Image::getSourceWidth() const float e2d::Image::getSourceWidth() const
{ {
if (_bitmap) if (_bitmap)
{ {
@ -107,7 +107,7 @@ double e2d::Image::getSourceWidth() const
} }
} }
double e2d::Image::getSourceHeight() const float e2d::Image::getSourceHeight() const
{ {
if (_bitmap) if (_bitmap)
{ {
@ -131,12 +131,12 @@ e2d::Size e2d::Image::getSourceSize() const
} }
} }
double e2d::Image::getCropX() const float e2d::Image::getCropX() const
{ {
return _cropRect.origin.x; return _cropRect.origin.x;
} }
double e2d::Image::getCropY() const float e2d::Image::getCropY() const
{ {
return _cropRect.origin.y; return _cropRect.origin.y;
} }

View File

@ -8,7 +8,7 @@ e2d::Point::Point()
y = 0; y = 0;
} }
e2d::Point::Point(double x, double y) e2d::Point::Point(float x, float y)
{ {
this->x = x; this->x = x;
this->y = y; this->y = y;
@ -30,12 +30,12 @@ e2d::Point e2d::Point::operator-(Point const & p) const
return Point(x - p.x, y - p.y); return Point(x - p.x, y - p.y);
} }
e2d::Point e2d::Point::operator*(double const & value) const e2d::Point e2d::Point::operator*(float const & value) const
{ {
return Point(x * value, y * value); return Point(x * value, y * value);
} }
e2d::Point e2d::Point::operator/(double const & value) const e2d::Point e2d::Point::operator/(float const & value) const
{ {
return Point(x / value, y / value); return Point(x / value, y / value);
} }
@ -45,7 +45,7 @@ e2d::Point::operator e2d::Size() const
return Size(x, y); return Size(x, y);
} }
double e2d::Point::distance(const Point &p1, const Point &p2) float e2d::Point::distance(const Point &p1, const Point &p2)
{ {
return sqrt( return sqrt(
(p1.x - p2.x) * (p1.x - p2.x) + (p1.x - p2.x) * (p1.x - p2.x) +

View File

@ -2,10 +2,10 @@
e2d::Rect::Rect(void) e2d::Rect::Rect(void)
{ {
setRect(0.0, 0.0, 0.0, 0.0); setRect(0.f, 0.f, 0.f, 0.f);
} }
e2d::Rect::Rect(double x, double y, double width, double height) e2d::Rect::Rect(float x, float y, float width, float height)
{ {
setRect(x, y, width, height); setRect(x, y, width, height);
} }
@ -31,7 +31,7 @@ bool e2d::Rect::operator==(const Rect & rect) const
return (origin == rect.origin) && (size == rect.size); return (origin == rect.origin) && (size == rect.size);
} }
void e2d::Rect::setRect(double x, double y, double width, double height) void e2d::Rect::setRect(float x, float y, float width, float height)
{ {
origin.x = x; origin.x = x;
origin.y = y; origin.y = y;

View File

@ -6,7 +6,7 @@ e2d::Size::Size()
height = 0; height = 0;
} }
e2d::Size::Size(double width, double height) e2d::Size::Size(float width, float height)
{ {
this->width = width; this->width = width;
this->height = height; this->height = height;
@ -28,12 +28,12 @@ e2d::Size e2d::Size::operator-(Size const & size) const
return Size(width - size.width, height - size.height); return Size(width - size.width, height - size.height);
} }
e2d::Size e2d::Size::operator*(double const & value) const e2d::Size e2d::Size::operator*(float const & value) const
{ {
return Size(width * value, height * value); return Size(width * value, height * value);
} }
e2d::Size e2d::Size::operator/(double const & value) const e2d::Size e2d::Size::operator/(float const & value) const
{ {
return Size(width / value, height / value); return Size(width / value, height / value);
} }

View File

@ -406,6 +406,15 @@ int e2d::String::toInt() const
return std::stoi(_str, 0, 10); return std::stoi(_str, 0, 10);
} }
float e2d::String::toFloat() const
{
if (_str.empty())
{
return 0.f;
}
return std::stof(_str, 0);
}
double e2d::String::toDouble() const double e2d::String::toDouble() const
{ {
if (_str.empty()) if (_str.empty())

View File

@ -10,12 +10,12 @@ e2d::MouseEvent::MouseEvent(UINT message, WPARAM wParam, LPARAM lParam)
{ {
} }
double e2d::MouseEvent::getX() const float e2d::MouseEvent::getX() const
{ {
return _pos.x; return _pos.x;
} }
double e2d::MouseEvent::getY() const float e2d::MouseEvent::getY() const
{ {
return _pos.y; return _pos.y;
} }
@ -35,7 +35,7 @@ bool e2d::MouseEvent::isCtrlDown() const
return _ctrlDown; return _ctrlDown;
} }
double e2d::MouseEvent::getWheelDelta() const float e2d::MouseEvent::getWheelDelta() const
{ {
return _wheelDelta; return _wheelDelta;
} }

View File

@ -70,8 +70,8 @@ e2d::Node::Node()
, _extrapolate(Property::Origin) , _extrapolate(Property::Origin)
{ {
Point defPivot = Game::getInstance()->getConfig().getNodeDefaultPivot(); Point defPivot = Game::getInstance()->getConfig().getNodeDefaultPivot();
_pivotX = float(defPivot.x); _pivotX = defPivot.x;
_pivotY = float(defPivot.y); _pivotY = defPivot.y;
_collider.setShape(Game::getInstance()->getConfig().getDefaultColliderShape()); _collider.setShape(Game::getInstance()->getConfig().getDefaultColliderShape());
} }
@ -425,12 +425,12 @@ size_t e2d::Node::getHashName() const
return _hashName; return _hashName;
} }
double e2d::Node::getPosX() const float e2d::Node::getPosX() const
{ {
return _posX; return _posX;
} }
double e2d::Node::getPosY() const float e2d::Node::getPosY() const
{ {
return _posY; return _posY;
} }
@ -440,22 +440,22 @@ e2d::Point e2d::Node::getPos() const
return Point(_posX, _posY); return Point(_posX, _posY);
} }
double e2d::Node::getWidth() const float e2d::Node::getWidth() const
{ {
return _width * _scaleX; return _width * _scaleX;
} }
double e2d::Node::getHeight() const float e2d::Node::getHeight() const
{ {
return _height * _scaleY; return _height * _scaleY;
} }
double e2d::Node::getRealWidth() const float e2d::Node::getRealWidth() const
{ {
return _width; return _width;
} }
double e2d::Node::getRealHeight() const float e2d::Node::getRealHeight() const
{ {
return _height; return _height;
} }
@ -465,12 +465,12 @@ e2d::Size e2d::Node::getRealSize() const
return Size(_width, _height); return Size(_width, _height);
} }
double e2d::Node::getPivotX() const float e2d::Node::getPivotX() const
{ {
return _pivotX; return _pivotX;
} }
double e2d::Node::getPivotY() const float e2d::Node::getPivotY() const
{ {
return _pivotY; return _pivotY;
} }
@ -480,32 +480,32 @@ e2d::Size e2d::Node::getSize() const
return Size(getWidth(), getHeight()); return Size(getWidth(), getHeight());
} }
double e2d::Node::getScaleX() const float e2d::Node::getScaleX() const
{ {
return _scaleX; return _scaleX;
} }
double e2d::Node::getScaleY() const float e2d::Node::getScaleY() const
{ {
return _scaleY; return _scaleY;
} }
double e2d::Node::getSkewX() const float e2d::Node::getSkewX() const
{ {
return _skewAngleX; return _skewAngleX;
} }
double e2d::Node::getSkewY() const float e2d::Node::getSkewY() const
{ {
return _skewAngleY; return _skewAngleY;
} }
double e2d::Node::getRotation() const float e2d::Node::getRotation() const
{ {
return _rotation; return _rotation;
} }
double e2d::Node::getOpacity() const float e2d::Node::getOpacity() const
{ {
return _realOpacity; return _realOpacity;
} }
@ -554,12 +554,12 @@ void e2d::Node::setOrder(int order)
} }
} }
void e2d::Node::setPosX(double x) void e2d::Node::setPosX(float x)
{ {
this->setPos(x, _posY); this->setPos(x, _posY);
} }
void e2d::Node::setPosY(double y) void e2d::Node::setPosY(float y)
{ {
this->setPos(_posX, y); this->setPos(_posX, y);
} }
@ -569,13 +569,13 @@ void e2d::Node::setPos(const Point & p)
this->setPos(p.x, p.y); this->setPos(p.x, p.y);
} }
void e2d::Node::setPos(double x, double y) void e2d::Node::setPos(float x, float y)
{ {
if (_posX == x && _posY == y) if (_posX == x && _posY == y)
return; return;
_posX = float(x); _posX = x;
_posY = float(y); _posY = y;
_needTransform = true; _needTransform = true;
} }
@ -588,17 +588,17 @@ void e2d::Node::setPosFixed(bool fixed)
_needTransform = true; _needTransform = true;
} }
void e2d::Node::movePosX(double x) void e2d::Node::movePosX(float x)
{ {
this->movePos(x, 0); this->movePos(x, 0);
} }
void e2d::Node::movePosY(double y) void e2d::Node::movePosY(float y)
{ {
this->movePos(0, y); this->movePos(0, y);
} }
void e2d::Node::movePos(double x, double y) void e2d::Node::movePos(float x, float y)
{ {
this->setPos(_posX + x, _posY + y); this->setPos(_posX + x, _posY + y);
} }
@ -608,107 +608,107 @@ void e2d::Node::movePos(const Vector2 & v)
this->movePos(v.x, v.y); this->movePos(v.x, v.y);
} }
void e2d::Node::setScaleX(double scaleX) void e2d::Node::setScaleX(float scaleX)
{ {
this->setScale(scaleX, _scaleY); this->setScale(scaleX, _scaleY);
} }
void e2d::Node::setScaleY(double scaleY) void e2d::Node::setScaleY(float scaleY)
{ {
this->setScale(_scaleX, scaleY); this->setScale(_scaleX, scaleY);
} }
void e2d::Node::setScale(double scale) void e2d::Node::setScale(float scale)
{ {
this->setScale(scale, scale); this->setScale(scale, scale);
} }
void e2d::Node::setScale(double scaleX, double scaleY) void e2d::Node::setScale(float scaleX, float scaleY)
{ {
if (_scaleX == scaleX && _scaleY == scaleY) if (_scaleX == scaleX && _scaleY == scaleY)
return; return;
_scaleX = float(scaleX); _scaleX = scaleX;
_scaleY = float(scaleY); _scaleY = scaleY;
_needTransform = true; _needTransform = true;
} }
void e2d::Node::setSkewX(double angleX) void e2d::Node::setSkewX(float angleX)
{ {
this->setSkew(angleX, _skewAngleY); this->setSkew(angleX, _skewAngleY);
} }
void e2d::Node::setSkewY(double angleY) void e2d::Node::setSkewY(float angleY)
{ {
this->setSkew(_skewAngleX, angleY); this->setSkew(_skewAngleX, angleY);
} }
void e2d::Node::setSkew(double angleX, double angleY) void e2d::Node::setSkew(float angleX, float angleY)
{ {
if (_skewAngleX == angleX && _skewAngleY == angleY) if (_skewAngleX == angleX && _skewAngleY == angleY)
return; return;
_skewAngleX = float(angleX); _skewAngleX = angleX;
_skewAngleY = float(angleY); _skewAngleY = angleY;
_needTransform = true; _needTransform = true;
} }
void e2d::Node::setRotation(double angle) void e2d::Node::setRotation(float angle)
{ {
if (_rotation == angle) if (_rotation == angle)
return; return;
_rotation = float(angle); _rotation = angle;
_needTransform = true; _needTransform = true;
} }
void e2d::Node::setOpacity(double opacity) void e2d::Node::setOpacity(float opacity)
{ {
if (_realOpacity == opacity) if (_realOpacity == opacity)
return; return;
_displayOpacity = _realOpacity = std::min(std::max(float(opacity), 0.f), 1.f); _displayOpacity = _realOpacity = std::min(std::max(opacity, 0.f), 1.f);
// ¸üнڵã͸Ã÷¶È // ¸üнڵã͸Ã÷¶È
_updateOpacity(); _updateOpacity();
} }
void e2d::Node::setPivotX(double pivotX) void e2d::Node::setPivotX(float pivotX)
{ {
this->setPivot(pivotX, _pivotY); this->setPivot(pivotX, _pivotY);
} }
void e2d::Node::setPivotY(double pivotY) void e2d::Node::setPivotY(float pivotY)
{ {
this->setPivot(_pivotX, pivotY); this->setPivot(_pivotX, pivotY);
} }
void e2d::Node::setPivot(double pivotX, double pivotY) void e2d::Node::setPivot(float pivotX, float pivotY)
{ {
if (_pivotX == pivotX && _pivotY == pivotY) if (_pivotX == pivotX && _pivotY == pivotY)
return; return;
_pivotX = std::min(std::max(float(pivotX), 0.f), 1.f); _pivotX = std::min(std::max(pivotX, 0.f), 1.f);
_pivotY = std::min(std::max(float(pivotY), 0.f), 1.f); _pivotY = std::min(std::max(pivotY, 0.f), 1.f);
_needTransform = true; _needTransform = true;
} }
void e2d::Node::setWidth(double width) void e2d::Node::setWidth(float width)
{ {
this->setSize(width, _height); this->setSize(width, _height);
} }
void e2d::Node::setHeight(double height) void e2d::Node::setHeight(float height)
{ {
this->setSize(_width, height); this->setSize(_width, height);
} }
void e2d::Node::setSize(double width, double height) void e2d::Node::setSize(float width, float height)
{ {
if (_width == width && _height == height) if (_width == width && _height == height)
return; return;
_width = float(width); _width = width;
_height = float(height); _height = height;
_needTransform = true; _needTransform = true;
} }
@ -953,7 +953,7 @@ bool e2d::Node::containsPoint(const Point& point)
{ {
BOOL ret = 0; BOOL ret = 0;
_outline->FillContainsPoint( _outline->FillContainsPoint(
D2D1::Point2F(float(point.x), float(point.y)), D2D1::Point2F(point.x, point.y),
D2D1::Matrix3x2F::Identity(), D2D1::Matrix3x2F::Identity(),
&ret &ret
); );

View File

@ -6,13 +6,13 @@ e2d::CircleShape::CircleShape()
this->setPivot(0.5, 0.5); this->setPivot(0.5, 0.5);
} }
e2d::CircleShape::CircleShape(double radius) e2d::CircleShape::CircleShape(float radius)
{ {
this->setRadius(radius); this->setRadius(radius);
this->setPivot(0.5, 0.5); this->setPivot(0.5, 0.5);
} }
e2d::CircleShape::CircleShape(Point center, double radius) e2d::CircleShape::CircleShape(Point center, float radius)
{ {
this->setRadius(radius); this->setRadius(radius);
this->setPos(center); this->setPos(center);
@ -23,14 +23,14 @@ e2d::CircleShape::~CircleShape()
{ {
} }
double e2d::CircleShape::getRadius() const float e2d::CircleShape::getRadius() const
{ {
return _radius; return _radius;
} }
void e2d::CircleShape::setRadius(double radius) void e2d::CircleShape::setRadius(float radius)
{ {
_radius = float(radius); _radius = radius;
Node::setSize(radius * 2, radius * 2); Node::setSize(radius * 2, radius * 2);
} }

View File

@ -7,14 +7,14 @@ e2d::EllipseShape::EllipseShape()
this->setPivot(0.5, 0.5); this->setPivot(0.5, 0.5);
} }
e2d::EllipseShape::EllipseShape(double radiusX, double radiusY) e2d::EllipseShape::EllipseShape(float radiusX, float radiusY)
{ {
this->setRadiusX(radiusX); this->setRadiusX(radiusX);
this->setRadiusY(radiusY); this->setRadiusY(radiusY);
this->setPivot(0.5, 0.5); this->setPivot(0.5, 0.5);
} }
e2d::EllipseShape::EllipseShape(Point center, double radiusX, double radiusY) e2d::EllipseShape::EllipseShape(Point center, float radiusX, float radiusY)
{ {
this->setRadiusX(radiusX); this->setRadiusX(radiusX);
this->setRadiusY(radiusY); this->setRadiusY(radiusY);
@ -26,25 +26,25 @@ e2d::EllipseShape::~EllipseShape()
{ {
} }
double e2d::EllipseShape::getRadiusX() const float e2d::EllipseShape::getRadiusX() const
{ {
return _radiusX; return _radiusX;
} }
double e2d::EllipseShape::getRadiusY() const float e2d::EllipseShape::getRadiusY() const
{ {
return _radiusY; return _radiusY;
} }
void e2d::EllipseShape::setRadiusX(double radiusX) void e2d::EllipseShape::setRadiusX(float radiusX)
{ {
_radiusX = float(radiusX); _radiusX = radiusX;
Node::setWidth(radiusX * 2); Node::setWidth(radiusX * 2);
} }
void e2d::EllipseShape::setRadiusY(double radiusY) void e2d::EllipseShape::setRadiusY(float radiusY)
{ {
_radiusY = float(radiusY); _radiusY = radiusY;
Node::setHeight(radiusY * 2); Node::setHeight(radiusY * 2);
} }

View File

@ -6,16 +6,16 @@ e2d::RoundRectShape::RoundRectShape()
{ {
} }
e2d::RoundRectShape::RoundRectShape(Size size, double radiusX, double radiusY) e2d::RoundRectShape::RoundRectShape(Size size, float radiusX, float radiusY)
: _radiusX(float(radiusX)) : _radiusX(radiusX)
, _radiusY(float(radiusY)) , _radiusY(radiusY)
{ {
this->setSize(size); this->setSize(size);
} }
e2d::RoundRectShape::RoundRectShape(Point topLeft, Size size, double radiusX, double radiusY) e2d::RoundRectShape::RoundRectShape(Point topLeft, Size size, float radiusX, float radiusY)
: _radiusX(float(radiusX)) : _radiusX(radiusX)
, _radiusY(float(radiusY)) , _radiusY(radiusY)
{ {
this->setPivot(0, 0); this->setPivot(0, 0);
this->setPos(topLeft); this->setPos(topLeft);
@ -26,24 +26,24 @@ e2d::RoundRectShape::~RoundRectShape()
{ {
} }
double e2d::RoundRectShape::getRadiusX() const float e2d::RoundRectShape::getRadiusX() const
{ {
return _radiusX; return _radiusX;
} }
double e2d::RoundRectShape::getRadiusY() const float e2d::RoundRectShape::getRadiusY() const
{ {
return _radiusY; return _radiusY;
} }
void e2d::RoundRectShape::setRadiusX(double radiusX) void e2d::RoundRectShape::setRadiusX(float radiusX)
{ {
_radiusX = float(radiusX); _radiusX = radiusX;
} }
void e2d::RoundRectShape::setRadiusY(double radiusY) void e2d::RoundRectShape::setRadiusY(float radiusY)
{ {
_radiusY = float(radiusY); _radiusY = radiusY;
} }
void e2d::RoundRectShape::_renderLine() const void e2d::RoundRectShape::_renderLine() const

View File

@ -59,7 +59,7 @@ e2d::Color e2d::Shape::getLineColor() const
return _lineColor; return _lineColor;
} }
double e2d::Shape::getStrokeWidth() const float e2d::Shape::getStrokeWidth() const
{ {
return _strokeWidth; return _strokeWidth;
} }
@ -79,9 +79,9 @@ void e2d::Shape::setLineColor(Color lineColor)
_lineColor = lineColor; _lineColor = lineColor;
} }
void e2d::Shape::setStrokeWidth(double strokeWidth) void e2d::Shape::setStrokeWidth(float strokeWidth)
{ {
_strokeWidth = float(strokeWidth) * 2; _strokeWidth = strokeWidth * 2;
} }
void e2d::Shape::setStyle(Style style) void e2d::Shape::setStyle(Style style)

View File

@ -82,8 +82,8 @@ void e2d::Sprite::crop(const Rect& cropRect)
{ {
_image->crop(cropRect); _image->crop(cropRect);
Node::setSize( Node::setSize(
std::min(std::max(cropRect.size.width, 0.0), _image->getSourceWidth() - _image->getCropX()), std::min(std::max(cropRect.size.width, 0.f), _image->getSourceWidth() - _image->getCropX()),
std::min(std::max(cropRect.size.height, 0.0), _image->getSourceHeight() - _image->getCropY()) std::min(std::max(cropRect.size.height, 0.f), _image->getSourceHeight() - _image->getCropY())
); );
} }
@ -97,8 +97,8 @@ void e2d::Sprite::onRender() const
if (_image && _image->getBitmap()) if (_image && _image->getBitmap())
{ {
// »ñȡͼƬ²Ã¼ôλÖà // »ñȡͼƬ²Ã¼ôλÖÃ
float fCropX = float(_image->getCropX()); float fCropX = _image->getCropX();
float fCropY = float(_image->getCropY()); float fCropY = _image->getCropY();
// äÖȾͼƬ // äÖȾͼƬ
Renderer::getInstance()->getRenderTarget()->DrawBitmap( Renderer::getInstance()->getRenderTarget()->DrawBitmap(
_image->getBitmap(), _image->getBitmap(),

View File

@ -8,13 +8,13 @@ e2d::Text::Style::Style()
: color(Color::White) : color(Color::White)
, alignment(Align::Left) , alignment(Align::Left)
, wrapping(false) , wrapping(false)
, wrappingWidth(0.0) , wrappingWidth(0.f)
, lineSpacing(0.0) , lineSpacing(0.f)
, hasUnderline(false) , hasUnderline(false)
, hasStrikethrough(false) , hasStrikethrough(false)
, hasOutline(true) , hasOutline(true)
, outlineColor(Color(Color::Black, 0.5)) , outlineColor(Color(Color::Black, 0.5))
, outlineWidth(1.0) , outlineWidth(1.f)
, outlineJoin(LineJoin::Round) , outlineJoin(LineJoin::Round)
{} {}
@ -22,13 +22,13 @@ e2d::Text::Style::Style(
Color color, Color color,
Align alignment, Align alignment,
bool wrapping, bool wrapping,
double wrappingWidth, float wrappingWidth,
double lineSpacing, float lineSpacing,
bool hasUnderline, bool hasUnderline,
bool hasStrikethrough, bool hasStrikethrough,
bool hasOutline, bool hasOutline,
Color outlineColor, Color outlineColor,
double outlineWidth, float outlineWidth,
LineJoin outlineJoin LineJoin outlineJoin
) )
: color(color) : color(color)
@ -94,7 +94,7 @@ e2d::String e2d::Text::getFontFamily() const
return _font.family; return _font.family;
} }
double e2d::Text::getFontSize() const float e2d::Text::getFontSize() const
{ {
return _font.size; return _font.size;
} }
@ -114,7 +114,7 @@ e2d::Color e2d::Text::getOutlineColor() const
return _style.outlineColor; return _style.outlineColor;
} }
double e2d::Text::getOutlineWidth() const float e2d::Text::getOutlineWidth() const
{ {
return _style.outlineWidth; return _style.outlineWidth;
} }
@ -182,7 +182,7 @@ void e2d::Text::setFontFamily(const String& family)
_reset(); _reset();
} }
void e2d::Text::setFontSize(double size) void e2d::Text::setFontSize(float size)
{ {
_font.size = size; _font.size = size;
_reset(); _reset();
@ -214,11 +214,11 @@ void e2d::Text::setWrapping(bool wrapping)
} }
} }
void e2d::Text::setWrappingWidth(double wrappingWidth) void e2d::Text::setWrappingWidth(float wrappingWidth)
{ {
if (_style.wrappingWidth != wrappingWidth) if (_style.wrappingWidth != wrappingWidth)
{ {
_style.wrappingWidth = std::max(wrappingWidth, 0.0); _style.wrappingWidth = std::max(wrappingWidth, 0.f);
if (_style.wrapping) if (_style.wrapping)
{ {
@ -227,7 +227,7 @@ void e2d::Text::setWrappingWidth(double wrappingWidth)
} }
} }
void e2d::Text::setLineSpacing(double lineSpacing) void e2d::Text::setLineSpacing(float lineSpacing)
{ {
if (_style.lineSpacing != lineSpacing) if (_style.lineSpacing != lineSpacing)
{ {
@ -277,7 +277,7 @@ void e2d::Text::setOutlineColor(Color outlineColor)
_style.outlineColor = outlineColor; _style.outlineColor = outlineColor;
} }
void e2d::Text::setOutlineWidth(double outlineWidth) void e2d::Text::setOutlineWidth(float outlineWidth)
{ {
_style.outlineWidth = outlineWidth; _style.outlineWidth = outlineWidth;
} }
@ -302,7 +302,7 @@ void e2d::Text::onRender() const
_style.color.toD2DColorF(), _style.color.toD2DColorF(),
_style.hasOutline, _style.hasOutline,
_style.outlineColor.toD2DColorF(), _style.outlineColor.toD2DColorF(),
float(_style.outlineWidth), _style.outlineWidth,
D2D1_LINE_JOIN(_style.outlineJoin) D2D1_LINE_JOIN(_style.outlineJoin)
); );
_textLayout->Draw(nullptr, pTextRenderer, 0, 0); _textLayout->Draw(nullptr, pTextRenderer, 0, 0);
@ -327,7 +327,7 @@ void e2d::Text::_createFormat()
DWRITE_FONT_WEIGHT(_font.weight), DWRITE_FONT_WEIGHT(_font.weight),
_font.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL, _font.italic ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
float(_font.size), _font.size,
L"", L"",
&_textFormat &_textFormat
); );
@ -343,7 +343,7 @@ void e2d::Text::_createFormat()
// 设置文字对齐方式 // 设置文字对齐方式
_textFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT(_style.alignment)); _textFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT(_style.alignment));
// 设置行间距 // 设置行间距
if (_style.lineSpacing == 0.0) if (_style.lineSpacing == 0.f)
{ {
_textFormat->SetLineSpacing(DWRITE_LINE_SPACING_METHOD_DEFAULT, 0, 0); _textFormat->SetLineSpacing(DWRITE_LINE_SPACING_METHOD_DEFAULT, 0, 0);
} }
@ -351,8 +351,8 @@ void e2d::Text::_createFormat()
{ {
_textFormat->SetLineSpacing( _textFormat->SetLineSpacing(
DWRITE_LINE_SPACING_METHOD_UNIFORM, DWRITE_LINE_SPACING_METHOD_UNIFORM,
float(_style.lineSpacing), _style.lineSpacing,
float(_style.lineSpacing) * 0.8f _style.lineSpacing * 0.8f
); );
} }
// 打开文本自动换行时,设置换行属性 // 打开文本自动换行时,设置换行属性
@ -395,7 +395,7 @@ void e2d::Text::_createLayout()
(const WCHAR *)_text, (const WCHAR *)_text,
length, length,
_textFormat, _textFormat,
float(_style.wrappingWidth), _style.wrappingWidth,
0, 0,
&_textLayout &_textLayout
); );

View File

@ -18,7 +18,7 @@ void e2d::Data::saveInt(int value)
); );
} }
void e2d::Data::saveDouble(double value) void e2d::Data::saveDouble(float value)
{ {
::WritePrivateProfileString( ::WritePrivateProfileString(
(LPCWSTR)_field, (LPCWSTR)_field,
@ -58,7 +58,7 @@ int e2d::Data::getInt(int defaultValue)
); );
} }
double e2d::Data::getDouble(double defaultValue) float e2d::Data::getDouble(float defaultValue)
{ {
wchar_t temp[32] = { 0 }; wchar_t temp[32] = { 0 };
::GetPrivateProfileString((LPCWSTR)_field, (LPCWSTR)_key, (LPCWSTR)String::parse(defaultValue), temp, 31, (LPCWSTR)_dataPath); ::GetPrivateProfileString((LPCWSTR)_field, (LPCWSTR)_key, (LPCWSTR)String::parse(defaultValue), temp, 31, (LPCWSTR)_dataPath);

View File

@ -309,11 +309,11 @@ IXAudio2SourceVoice * e2d::Music::getIXAudio2SourceVoice() const
return _voice; return _voice;
} }
bool e2d::Music::setVolume(double volume) bool e2d::Music::setVolume(float volume)
{ {
if (_voice) if (_voice)
{ {
return SUCCEEDED(_voice->SetVolume(float(volume))); return SUCCEEDED(_voice->SetVolume(volume));
} }
return false; return false;
} }

View File

@ -160,14 +160,14 @@ bool e2d::Player::isPlaying(const Resource& res)
return false; return false;
} }
double e2d::Player::getVolume() float e2d::Player::getVolume()
{ {
return _volume; return _volume;
} }
void e2d::Player::setVolume(double volume) void e2d::Player::setVolume(float volume)
{ {
_volume = std::min(std::max(float(volume), -224.f), 224.f); _volume = std::min(std::max(volume, -224.f), 224.f);
for (auto pair : _musicList) for (auto pair : _musicList)
{ {
pair.second->setVolume(_volume); pair.second->setVolume(_volume);

View File

@ -6,20 +6,20 @@ e2d::Task::Task(const Function & func, const String & name)
, _stopped(false) , _stopped(false)
, _runTimes(0) , _runTimes(0)
, _totalTimes(-1) , _totalTimes(-1)
, _delay(0.0) , _delay(0.f)
, _lastTime(0.0) , _lastTime(0.f)
, _callback(func) , _callback(func)
, _name(name) , _name(name)
{ {
} }
e2d::Task::Task(const Function & func, double delay, int times, const String & name) e2d::Task::Task(const Function & func, float delay, int times, const String & name)
: _running(true) : _running(true)
, _stopped(false) , _stopped(false)
, _runTimes(0) , _runTimes(0)
, _totalTimes(times) , _totalTimes(times)
, _delay(std::max(delay, 0.0)) , _delay(std::max(delay, 0.f))
, _lastTime(0.0) , _lastTime(0.f)
, _callback(func) , _callback(func)
, _name(name) , _name(name)
{ {

View File

@ -1,7 +1,7 @@
#include "..\e2dtransition.h" #include "..\e2dtransition.h"
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::BoxTransition::BoxTransition(double duration) e2d::BoxTransition::BoxTransition(float duration)
: Transition(duration) : Transition(duration)
{ {
} }
@ -17,10 +17,10 @@ void e2d::BoxTransition::_updateCustom()
if (_delta <= 0.5) if (_delta <= 0.5)
{ {
_outLayerParam.contentBounds = D2D1::RectF( _outLayerParam.contentBounds = D2D1::RectF(
float(_windowSize.width * _delta), _windowSize.width * _delta,
float(_windowSize.height * _delta), _windowSize.height * _delta,
float(_windowSize.width * (1 - _delta)), _windowSize.width * (1 - _delta),
float(_windowSize.height * (1 - _delta)) _windowSize.height * (1 - _delta)
); );
} }
else else
@ -28,10 +28,10 @@ void e2d::BoxTransition::_updateCustom()
_outLayerParam.opacity = 0; _outLayerParam.opacity = 0;
_inLayerParam.opacity = 1; _inLayerParam.opacity = 1;
_inLayerParam.contentBounds = D2D1::RectF( _inLayerParam.contentBounds = D2D1::RectF(
float(_windowSize.width * (1 - _delta)), _windowSize.width * (1 - _delta),
float(_windowSize.height * (1 - _delta)), _windowSize.height * (1 - _delta),
float(_windowSize.width * _delta), _windowSize.width * _delta,
float(_windowSize.height * _delta) _windowSize.height * _delta
); );
if (_delta >= 1) if (_delta >= 1)
{ {

View File

@ -1,7 +1,7 @@
#include "..\e2dtransition.h" #include "..\e2dtransition.h"
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::EmergeTransition::EmergeTransition(double duration) e2d::EmergeTransition::EmergeTransition(float duration)
: Transition(duration) : Transition(duration)
{ {
} }
@ -15,8 +15,8 @@ void e2d::EmergeTransition::_init(Scene * prev, Scene * next)
void e2d::EmergeTransition::_updateCustom() void e2d::EmergeTransition::_updateCustom()
{ {
_outLayerParam.opacity = float(1 - _delta); _outLayerParam.opacity = 1 - _delta;
_inLayerParam.opacity = float(_delta); _inLayerParam.opacity = _delta;
if (_delta >= 1) if (_delta >= 1)
{ {

View File

@ -1,7 +1,7 @@
#include "..\e2dtransition.h" #include "..\e2dtransition.h"
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::FadeTransition::FadeTransition(double duration) e2d::FadeTransition::FadeTransition(float duration)
: Transition(duration) : Transition(duration)
{ {
} }
@ -17,13 +17,13 @@ void e2d::FadeTransition::_updateCustom()
{ {
if (_delta < 0.5) if (_delta < 0.5)
{ {
_outLayerParam.opacity = 1 - float(_delta) * 2; _outLayerParam.opacity = 1 - _delta * 2;
_inLayerParam.opacity = 0; _inLayerParam.opacity = 0;
} }
else else
{ {
_outLayerParam.opacity = 0; _outLayerParam.opacity = 0;
_inLayerParam.opacity = float(_delta - 0.5) * 2; _inLayerParam.opacity = (_delta - 0.5f) * 2;
if (_delta >= 1) if (_delta >= 1)
{ {
this->_stop(); this->_stop();

View File

@ -1,7 +1,7 @@
#include "..\e2dtransition.h" #include "..\e2dtransition.h"
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::MoveTransition::MoveTransition(double duration, Direction direction) e2d::MoveTransition::MoveTransition(float duration, Direction direction)
: Transition(duration) : Transition(duration)
, _direction(direction) , _direction(direction)
{ {
@ -11,8 +11,8 @@ void e2d::MoveTransition::_init(Scene * prev, Scene * next)
{ {
Transition::_init(prev, next); Transition::_init(prev, next);
double width = _windowSize.width; float width = _windowSize.width;
double height = _windowSize.height; float height = _windowSize.height;
if (_direction == Direction::Up) if (_direction == Direction::Up)
{ {
_posDelta = Vector2(0, -height); _posDelta = Vector2(0, -height);

View File

@ -2,7 +2,7 @@
#include "..\e2dtransition.h" #include "..\e2dtransition.h"
#include "..\e2dnode.h" #include "..\e2dnode.h"
e2d::Transition::Transition(double duration) e2d::Transition::Transition(float duration)
: _end(false) : _end(false)
, _last() , _last()
, _delta(0) , _delta(0)
@ -13,7 +13,7 @@ e2d::Transition::Transition(double duration)
, _outLayerParam() , _outLayerParam()
, _inLayerParam() , _inLayerParam()
{ {
_duration = std::max(duration, 0.0); _duration = std::max(duration, 0.f);
} }
e2d::Transition::~Transition() e2d::Transition::~Transition()
@ -57,7 +57,7 @@ void e2d::Transition::_init(Scene * prev, Scene * next)
nullptr, nullptr,
D2D1_ANTIALIAS_MODE_PER_PRIMITIVE, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE,
D2D1::Matrix3x2F::Identity(), D2D1::Matrix3x2F::Identity(),
1.0, 1.f,
renderer->getSolidColorBrush(), renderer->getSolidColorBrush(),
D2D1_LAYER_OPTIONS_NONE D2D1_LAYER_OPTIONS_NONE
); );
@ -73,7 +73,7 @@ void e2d::Transition::_update()
else else
{ {
_delta = (Game::getInstance()->getTotalDuration() - _last).seconds() / _duration; _delta = (Game::getInstance()->getTotalDuration() - _last).seconds() / _duration;
_delta = std::min(_delta, 1.0); _delta = std::min(_delta, 1.f);
} }
this->_updateCustom(); this->_updateCustom();
@ -97,10 +97,10 @@ void e2d::Transition::_render()
{ {
Point rootPos = _outScene->getRoot()->getPos(); Point rootPos = _outScene->getRoot()->getPos();
auto clipRect = D2D1::RectF( auto clipRect = D2D1::RectF(
float(std::max(rootPos.x, 0.0)), std::max(rootPos.x, 0.f),
float(std::max(rootPos.y, 0.0)), std::max(rootPos.y, 0.f),
float(std::min(rootPos.x + _windowSize.width, _windowSize.width)), std::min(rootPos.x + _windowSize.width, _windowSize.width),
float(std::min(rootPos.y + _windowSize.height, _windowSize.height)) std::min(rootPos.y + _windowSize.height, _windowSize.height)
); );
pRT->SetTransform(D2D1::Matrix3x2F::Identity()); pRT->SetTransform(D2D1::Matrix3x2F::Identity());
pRT->PushAxisAlignedClip(clipRect, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); pRT->PushAxisAlignedClip(clipRect, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
@ -116,10 +116,10 @@ void e2d::Transition::_render()
{ {
Point rootPos = _inScene->getRoot()->getPos(); Point rootPos = _inScene->getRoot()->getPos();
auto clipRect = D2D1::RectF( auto clipRect = D2D1::RectF(
float(std::max(rootPos.x, 0.0)), std::max(rootPos.x, 0.f),
float(std::max(rootPos.y, 0.0)), std::max(rootPos.y, 0.f),
float(std::min(rootPos.x + _windowSize.width, _windowSize.width)), std::min(rootPos.x + _windowSize.width, _windowSize.width),
float(std::min(rootPos.y + _windowSize.height, _windowSize.height)) std::min(rootPos.y + _windowSize.height, _windowSize.height)
); );
pRT->SetTransform(D2D1::Matrix3x2F::Identity()); pRT->SetTransform(D2D1::Matrix3x2F::Identity());
pRT->PushAxisAlignedClip(clipRect, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); pRT->PushAxisAlignedClip(clipRect, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);

View File

@ -85,7 +85,7 @@ protected:
bool _done; bool _done;
bool _initialized; bool _initialized;
Node * _target; Node * _target;
double _last; float _last;
}; };
@ -96,7 +96,7 @@ class FiniteTimeAction :
public: public:
// 创建特定时长的持续动作 // 创建特定时长的持续动作
explicit FiniteTimeAction( explicit FiniteTimeAction(
double duration float duration
); );
// 重置动作 // 重置动作
@ -115,8 +115,8 @@ protected:
virtual void _resetTime() override; virtual void _resetTime() override;
protected: protected:
double _duration; float _duration;
double _delta; float _delta;
}; };
@ -126,7 +126,7 @@ class MoveBy :
{ {
public: public:
explicit MoveBy( explicit MoveBy(
double duration, /* 持续时长 */ float duration, /* 持续时长 */
Vector2 vector /* 移动距离 */ Vector2 vector /* 移动距离 */
); );
@ -158,7 +158,7 @@ class MoveTo :
{ {
public: public:
explicit MoveTo( explicit MoveTo(
double duration, /* 持续时长 */ float duration, /* 持续时长 */
Point pos /* 目的坐标 */ Point pos /* 目的坐标 */
); );
@ -189,9 +189,9 @@ class JumpBy :
{ {
public: public:
explicit JumpBy( explicit JumpBy(
double duration, /* 持续时长 */ float duration, /* 持续时长 */
const Vector2& vec, /* 跳跃距离 */ const Vector2& vec, /* 跳跃距离 */
double height, /* 跳跃高度 */ float height, /* 跳跃高度 */
int jumps = 1 /* 跳跃次数 */ int jumps = 1 /* 跳跃次数 */
); );
@ -213,7 +213,7 @@ protected:
protected: protected:
Point _startPos; Point _startPos;
Vector2 _deltaPos; Vector2 _deltaPos;
double _height; float _height;
int _jumps; int _jumps;
Point _prevPos; Point _prevPos;
}; };
@ -225,9 +225,9 @@ class JumpTo :
{ {
public: public:
explicit JumpTo( explicit JumpTo(
double duration, /* 持续时长 */ float duration, /* 持续时长 */
const Point& pos, /* 目的坐标 */ const Point& pos, /* 目的坐标 */
double height, /* 跳跃高度 */ float height, /* 跳跃高度 */
int jumps = 1 /* 跳跃次数 */ int jumps = 1 /* 跳跃次数 */
); );
@ -258,14 +258,14 @@ class ScaleBy :
{ {
public: public:
explicit ScaleBy( explicit ScaleBy(
double duration, /* 持续时长 */ float duration, /* 持续时长 */
double scale /* 相对变化值 */ float scale /* 相对变化值 */
); );
explicit ScaleBy( explicit ScaleBy(
double duration, /* 持续时长 */ float duration, /* 持续时长 */
double scaleX, /* 横向缩放相对变化值 */ float scaleX, /* 横向缩放相对变化值 */
double scaleY /* 纵向缩放相对变化值 */ float scaleY /* 纵向缩放相对变化值 */
); );
// 获取该动作的拷贝对象 // 获取该动作的拷贝对象
@ -284,10 +284,10 @@ protected:
virtual void _update() override; virtual void _update() override;
protected: protected:
double _startScaleX; float _startScaleX;
double _startScaleY; float _startScaleY;
double _deltaX; float _deltaX;
double _deltaY; float _deltaY;
}; };
@ -297,14 +297,14 @@ class ScaleTo :
{ {
public: public:
explicit ScaleTo( explicit ScaleTo(
double duration, /* 持续时长 */ float duration, /* 持续时长 */
double scale /* 目标值 */ float scale /* 目标值 */
); );
explicit ScaleTo( explicit ScaleTo(
double duration, /* 持续时长 */ float duration, /* 持续时长 */
double scaleX, /* 横向缩放目标值 */ float scaleX, /* 横向缩放目标值 */
double scaleY /* 纵向缩放目标值 */ float scaleY /* 纵向缩放目标值 */
); );
// 获取该动作的拷贝对象 // 获取该动作的拷贝对象
@ -324,8 +324,8 @@ protected:
virtual void _init() override; virtual void _init() override;
protected: protected:
double _endScaleX; float _endScaleX;
double _endScaleY; float _endScaleY;
}; };
@ -335,8 +335,8 @@ class OpacityBy :
{ {
public: public:
explicit OpacityBy( explicit OpacityBy(
double duration, /* 持续时长 */ float duration, /* 持续时长 */
double opacity /* 相对变化值 */ float opacity /* 相对变化值 */
); );
// 获取该动作的拷贝对象 // 获取该动作的拷贝对象
@ -355,8 +355,8 @@ protected:
virtual void _update() override; virtual void _update() override;
protected: protected:
double _startVal; float _startVal;
double _deltaVal; float _deltaVal;
}; };
@ -366,8 +366,8 @@ class OpacityTo :
{ {
public: public:
explicit OpacityTo( explicit OpacityTo(
double duration, /* 持续时长 */ float duration, /* 持续时长 */
double opacity /* 目标值 */ float opacity /* 目标值 */
); );
// 获取该动作的拷贝对象 // 获取该动作的拷贝对象
@ -387,7 +387,7 @@ protected:
virtual void _init() override; virtual void _init() override;
protected: protected:
double _endVal; float _endVal;
}; };
@ -398,7 +398,7 @@ class FadeIn :
public: public:
// 创建淡入动作 // 创建淡入动作
explicit FadeIn( explicit FadeIn(
double duration /* 持续时长 */ float duration /* 持续时长 */
) )
: OpacityTo(duration, 1) : OpacityTo(duration, 1)
{ {
@ -416,7 +416,7 @@ class FadeOut :
public: public:
// 创建淡出动作 // 创建淡出动作
explicit FadeOut( explicit FadeOut(
double duration /* 持续时长 */ float duration /* 持续时长 */
) )
: OpacityTo(duration, 0) : OpacityTo(duration, 0)
{ {
@ -433,8 +433,8 @@ class RotateBy :
{ {
public: public:
explicit RotateBy( explicit RotateBy(
double duration, /* 持续时长 */ float duration, /* 持续时长 */
double rotation /* 相对变化值 */ float rotation /* 相对变化值 */
); );
// 获取该动作的拷贝对象 // 获取该动作的拷贝对象
@ -453,8 +453,8 @@ protected:
virtual void _update() override; virtual void _update() override;
protected: protected:
double _startVal; float _startVal;
double _deltaVal; float _deltaVal;
}; };
@ -464,8 +464,8 @@ class RotateTo :
{ {
public: public:
explicit RotateTo( explicit RotateTo(
double duration, /* 持续时长 */ float duration, /* 持续时长 */
double rotation /* 目标值 */ float rotation /* 目标值 */
); );
// 获取该动作的拷贝对象 // 获取该动作的拷贝对象
@ -485,7 +485,7 @@ protected:
virtual void _init() override; virtual void _init() override;
protected: protected:
double _endVal; float _endVal;
}; };
@ -495,7 +495,7 @@ class Delay :
{ {
public: public:
explicit Delay( explicit Delay(
double duration /* 延迟时长(秒) */ float duration /* 延迟时长(秒) */
); );
// 获取该动作的拷贝对象 // 获取该动作的拷贝对象
@ -520,8 +520,8 @@ protected:
virtual void _resetTime() override; virtual void _resetTime() override;
protected: protected:
double _delay; float _delay;
double _delta; float _delta;
}; };
@ -705,11 +705,11 @@ public:
); );
explicit Animation( explicit Animation(
double interval /* 帧间隔(秒) */ float interval /* 帧间隔(秒) */
); );
explicit Animation( explicit Animation(
double interval, /* 帧间隔(秒) */ float interval, /* 帧间隔(秒) */
const std::vector<Image*>& frames /* 关键帧数组 */ const std::vector<Image*>& frames /* 关键帧数组 */
); );
@ -726,14 +726,14 @@ public:
); );
// 获取帧间隔 // 获取帧间隔
double getInterval() const; float getInterval() const;
// 获取关键帧 // 获取关键帧
const std::vector<Image*>& getFrames() const; const std::vector<Image*>& getFrames() const;
// 设置每一帧的时间间隔 // 设置每一帧的时间间隔
void setInterval( void setInterval(
double interval /* 帧间隔(秒) */ float interval /* 帧间隔(秒) */
); );
// 获取帧动画的拷贝对象 // 获取帧动画的拷贝对象
@ -746,7 +746,7 @@ protected:
E2D_DISABLE_COPY(Animation); E2D_DISABLE_COPY(Animation);
protected: protected:
double _interval; float _interval;
std::vector<Image*> _frames; std::vector<Image*> _frames;
}; };

View File

@ -130,10 +130,10 @@ public:
String getTitle(); String getTitle();
// 資函完悶錐業 // 資函完悶錐業
double getWidth(); float getWidth();
// 資函完悶互業 // 資函完悶互業
double getHeight(); float getHeight();
// 資函完悶寄弌 // 資函完悶寄弌
Size getSize(); Size getSize();
@ -233,22 +233,22 @@ public:
); );
// 資誼報炎X已恫炎峙 // 資誼報炎X已恫炎峙
double getMouseX(); float getMouseX();
// 資誼報炎Y已恫炎峙 // 資誼報炎Y已恫炎峙
double getMouseY(); float getMouseY();
// 資誼報炎恫炎峙 // 資誼報炎恫炎峙
Point getMousePos(); Point getMousePos();
// 資誼報炎X已恫炎奐楚 // 資誼報炎X已恫炎奐楚
double getMouseDeltaX(); float getMouseDeltaX();
// 資誼報炎Y已恫炎奐楚 // 資誼報炎Y已恫炎奐楚
double getMouseDeltaY(); float getMouseDeltaY();
// 資誼報炎Z已<5A>報炎獄態<E78D84>恫炎奐楚 // 資誼報炎Z已<5A>報炎獄態<E78D84>恫炎奐楚
double getMouseDeltaZ(); float getMouseDeltaZ();
// 泡仟補秘譜姥彜蓑 // 泡仟補秘譜姥彜蓑
void update(); void update();

View File

@ -30,27 +30,27 @@ class Size;
class Point class Point
{ {
public: public:
double x; // X ×ø±ê float x; // X 坐标
double y; // Y ×ø±ê float y; // Y 坐标
public: public:
Point(); Point();
Point(double x, double y); Point(float x, float y);
Point(const Point& other); Point(const Point& other);
Point operator + (Point const & point) const; Point operator + (Point const & point) const;
Point operator - (Point const & point) const; Point operator - (Point const & point) const;
Point operator * (double const & point) const; Point operator * (float const & point) const;
Point operator / (double const & point) const; Point operator / (float const & point) const;
Point operator - () const; Point operator - () const;
bool operator== (const Point& point) const; bool operator== (const Point& point) const;
operator e2d::Size() const; operator e2d::Size() const;
// 判断两点间距离 // 判断两点间距离
static double distance(const Point&, const Point&); static float distance(const Point&, const Point&);
}; };
@ -62,20 +62,20 @@ typedef Point Vector2;
class Size class Size
{ {
public: public:
double width; // ¿í¶È float width; // 宽度
double height; // ¸ß¶È float height; // 高度
public: public:
Size(); Size();
Size(double width, double height); Size(float width, float height);
Size(const Size& other); Size(const Size& other);
Size operator + (Size const & size) const; Size operator + (Size const & size) const;
Size operator - (Size const & size) const; Size operator - (Size const & size) const;
Size operator * (double const & size) const; Size operator * (float const & size) const;
Size operator / (double const & size) const; Size operator / (float const & size) const;
Size operator - () const; Size operator - () const;
bool operator== (const Size& size) const; bool operator== (const Size& size) const;
@ -93,7 +93,7 @@ public:
public: public:
Rect(); Rect();
Rect(double x, double y, double width, double height); Rect(float x, float y, float width, float height);
Rect(const Point& pos, const Size& size); Rect(const Point& pos, const Size& size);
@ -105,10 +105,10 @@ public:
// 设置矩形 // 设置矩形
void setRect( void setRect(
double x, float x,
double y, float y,
double width, float width,
double height float height
); );
// 判断点是否在矩形内 // 判断点是否在矩形内
@ -202,6 +202,9 @@ public:
// 将字符串转化为 int 型 // 将字符串转化为 int 型
int toInt() const; int toInt() const;
// 将字符串转化为 float 型
float toFloat() const;
// 将字符串转化为 double 型 // 将字符串转化为 double 型
double toDouble() const; double toDouble() const;
@ -288,16 +291,16 @@ public:
Color(); Color();
Color( Color(
double r, float r,
double g, float g,
double b float b
); );
Color( Color(
double r, float r,
double g, float g,
double b, float b,
double alpha float alpha
); );
Color( Color(
@ -306,7 +309,7 @@ public:
Color( Color(
UINT rgb, UINT rgb,
double alpha float alpha
); );
D2D1_COLOR_F toD2DColorF() const; D2D1_COLOR_F toD2DColorF() const;
@ -358,7 +361,7 @@ public:
private: private:
void _init( void _init(
UINT rgb, UINT rgb,
double alpha float alpha
); );
private: private:
@ -422,7 +425,7 @@ public:
int milliseconds() const; int milliseconds() const;
// 获取秒数 // 获取秒数
double seconds() const; float seconds() const;
bool operator== (const Duration &) const; bool operator== (const Duration &) const;
bool operator!= (const Duration &) const; bool operator!= (const Duration &) const;
@ -470,7 +473,7 @@ class Font
{ {
public: public:
String family; // 字体族 String family; // 字体族
double size; // ×ֺŠfloat size; // 字号
UINT weight; // 粗细值 UINT weight; // 粗细值
bool italic; // 斜体 bool italic; // 斜体
@ -494,7 +497,7 @@ public:
explicit Font( explicit Font(
const String& family, const String& family,
double size = 22, float size = 22,
UINT weight = Font::Weight::Normal, UINT weight = Font::Weight::Normal,
bool italic = false bool italic = false
); );
@ -636,16 +639,16 @@ public:
LPARAM lParam LPARAM lParam
); );
double getX() const; float getX() const;
double getY() const; float getY() const;
Point getPos() const; Point getPos() const;
// 获取事件类型 // 获取事件类型
MouseEvent::Type getType() const; MouseEvent::Type getType() const;
double getWheelDelta() const; float getWheelDelta() const;
// Shift 键是否按下 // Shift 键是否按下
bool isShiftDown() const; bool isShiftDown() const;
@ -656,7 +659,7 @@ public:
protected: protected:
bool _shiftDown; bool _shiftDown;
bool _ctrlDown; bool _ctrlDown;
double _wheelDelta; float _wheelDelta;
Point _pos; Point _pos;
MouseEvent::Type _type; MouseEvent::Type _type;
}; };
@ -896,28 +899,28 @@ public:
); );
// 获取宽度 // 获取宽度
virtual double getWidth() const; virtual float getWidth() const;
// 获取高度 // 获取高度
virtual double getHeight() const; virtual float getHeight() const;
// 获取大小 // 获取大小
virtual Size getSize() const; virtual Size getSize() const;
// 获取源图片宽度 // 获取源图片宽度
virtual double getSourceWidth() const; virtual float getSourceWidth() const;
// 获取源图片高度 // 获取源图片高度
virtual double getSourceHeight() const; virtual float getSourceHeight() const;
// 获取源图片大小 // 获取源图片大小
virtual Size getSourceSize() const; virtual Size getSourceSize() const;
// 获取裁剪位置 X 坐标 // 获取裁剪位置 X 坐标
virtual double getCropX() const; virtual float getCropX() const;
// 获取裁剪位置 Y 坐标 // 获取裁剪位置 Y 坐标
virtual double getCropY() const; virtual float getCropY() const;
// 获取裁剪位置 // 获取裁剪位置
virtual Point getCropPos() const; virtual Point getCropPos() const;

View File

@ -23,17 +23,17 @@ public:
// 节点属性 // 节点属性
struct Property struct Property
{ {
double posX; // X 坐标 float posX; // X 坐标
double posY; // Y 坐标 float posY; // Y 坐标
double width; // 宽度 float width; // 宽度
double height; // 高度 float height; // 高度
double pivotX; // 中心点 X 坐标 float pivotX; // 中心点 X 坐标
double pivotY; // 中心点 Y 坐标 float pivotY; // 中心点 Y 坐标
double scaleX; // 横向缩放 float scaleX; // 横向缩放
double scaleY; // 纵向缩放 float scaleY; // 纵向缩放
double rotation; // 旋转角度 float rotation; // 旋转角度
double skewAngleX; // 横向倾斜角度 float skewAngleX; // 横向倾斜角度
double skewAngleY; // 纵向倾斜角度 float skewAngleY; // 纵向倾斜角度
Property operator+ (Property const & prop) const; Property operator+ (Property const & prop) const;
Property operator- (Property const & prop) const; Property operator- (Property const & prop) const;
@ -86,55 +86,55 @@ public:
int getOrder() const; int getOrder() const;
// 获取节点横坐标 // 获取节点横坐标
double getPosX() const; float getPosX() const;
// 获取节点纵坐标 // 获取节点纵坐标
double getPosY() const; float getPosY() const;
// 获取节点坐标 // 获取节点坐标
Point getPos() const; Point getPos() const;
// 获取节点宽度 // 获取节点宽度
double getWidth() const; float getWidth() const;
// 获取节点高度 // 获取节点高度
double getHeight() const; float getHeight() const;
// 获取节点宽度(不考虑缩放) // 获取节点宽度(不考虑缩放)
double getRealWidth() const; float getRealWidth() const;
// 获取节点高度(不考虑缩放) // 获取节点高度(不考虑缩放)
double getRealHeight() const; float getRealHeight() const;
// 获取节点大小(不考虑缩放) // 获取节点大小(不考虑缩放)
Size getRealSize() const; Size getRealSize() const;
// 获取节点的中心点 // 获取节点的中心点
double getPivotX() const; float getPivotX() const;
// 获取节点的中心点 // 获取节点的中心点
double getPivotY() const; float getPivotY() const;
// 获取节点大小 // 获取节点大小
Size getSize() const; Size getSize() const;
// 获取节点横向缩放比例 // 获取节点横向缩放比例
double getScaleX() const; float getScaleX() const;
// 获取节点纵向缩放比例 // 获取节点纵向缩放比例
double getScaleY() const; float getScaleY() const;
// 获取节点横向倾斜角度 // 获取节点横向倾斜角度
double getSkewX() const; float getSkewX() const;
// 获取节点纵向倾斜角度 // 获取节点纵向倾斜角度
double getSkewY() const; float getSkewY() const;
// 获取节点旋转角度 // 获取节点旋转角度
double getRotation() const; float getRotation() const;
// 获取节点透明度 // 获取节点透明度
double getOpacity() const; float getOpacity() const;
// 获取节点属性 // 获取节点属性
Property getProperty() const; Property getProperty() const;
@ -200,12 +200,12 @@ public:
// 设置节点横坐标 // 设置节点横坐标
virtual void setPosX( virtual void setPosX(
double x float x
); );
// 设置节点纵坐标 // 设置节点纵坐标
virtual void setPosY( virtual void setPosY(
double y float y
); );
// 设置节点坐标 // 设置节点坐标
@ -215,8 +215,8 @@ public:
// 设置节点坐标 // 设置节点坐标
virtual void setPos( virtual void setPos(
double x, float x,
double y float y
); );
// 节点坐标固定 // 节点坐标固定
@ -226,18 +226,18 @@ public:
// 移动节点 // 移动节点
virtual void movePosX( virtual void movePosX(
double x float x
); );
// 移动节点 // 移动节点
virtual void movePosY( virtual void movePosY(
double y float y
); );
// 移动节点 // 移动节点
virtual void movePos( virtual void movePos(
double x, float x,
double y float y
); );
// 移动节点 // 移动节点
@ -254,92 +254,92 @@ public:
// 设置横向缩放比例 // 设置横向缩放比例
// 默认为 1.0 // 默认为 1.0
virtual void setScaleX( virtual void setScaleX(
double scaleX float scaleX
); );
// 设置纵向缩放比例 // 设置纵向缩放比例
// 默认为 1.0 // 默认为 1.0
virtual void setScaleY( virtual void setScaleY(
double scaleY float scaleY
); );
// 设置缩放比例 // 设置缩放比例
// 默认为 (1.0, 1.0) // 默认为 (1.0, 1.0)
virtual void setScale( virtual void setScale(
double scaleX, float scaleX,
double scaleY float scaleY
); );
// 设置缩放比例 // 设置缩放比例
// 默认为 1.0 // 默认为 1.0
virtual void setScale( virtual void setScale(
double scale float scale
); );
// 设置横向倾斜角度 // 设置横向倾斜角度
// 默认为 0 // 默认为 0
virtual void setSkewX( virtual void setSkewX(
double angleX float angleX
); );
// 设置纵向倾斜角度 // 设置纵向倾斜角度
// 默认为 0 // 默认为 0
virtual void setSkewY( virtual void setSkewY(
double angleY float angleY
); );
// 设置倾斜角度 // 设置倾斜角度
// 默认为 (0, 0) // 默认为 (0, 0)
virtual void setSkew( virtual void setSkew(
double angleX, float angleX,
double angleY float angleY
); );
// 设置旋转角度 // 设置旋转角度
// 默认为 0 // 默认为 0
virtual void setRotation( virtual void setRotation(
double rotation float rotation
); );
// 设置透明度 // 设置透明度
// 默认为 1.0, 范围 [0, 1] // 默认为 1.0, 范围 [0, 1]
virtual void setOpacity( virtual void setOpacity(
double opacity float opacity
); );
// 设置中心点的横向位置 // 设置中心点的横向位置
// 默认为 0, 范围 [0, 1] // 默认为 0, 范围 [0, 1]
virtual void setPivotX( virtual void setPivotX(
double pivotX float pivotX
); );
// 设置中心点的纵向位置 // 设置中心点的纵向位置
// 默认为 0, 范围 [0, 1] // 默认为 0, 范围 [0, 1]
virtual void setPivotY( virtual void setPivotY(
double pivotY float pivotY
); );
// 设置中心点位置 // 设置中心点位置
// 默认为 (0, 0), 范围 [0, 1] // 默认为 (0, 0), 范围 [0, 1]
virtual void setPivot( virtual void setPivot(
double pivotX, float pivotX,
double pivotY float pivotY
); );
// 修改节点宽度 // 修改节点宽度
virtual void setWidth( virtual void setWidth(
double width float width
); );
// 修改节点高度 // 修改节点高度
virtual void setHeight( virtual void setHeight(
double height float height
); );
// 修改节点大小 // 修改节点大小
virtual void setSize( virtual void setSize(
double width, float width,
double height float height
); );
// 修改节点大小 // 修改节点大小
@ -558,13 +558,13 @@ public:
Color color; // 颜色 Color color; // 颜色
Align alignment; // 对齐方式 Align alignment; // 对齐方式
bool wrapping; // 打开自动换行 bool wrapping; // 打开自动换行
double wrappingWidth; // 自动换行宽度 float wrappingWidth; // 自动换行宽度
double lineSpacing; // 行间距 float lineSpacing; // 行间距
bool hasUnderline; // 下划线 bool hasUnderline; // 下划线
bool hasStrikethrough; // 删除线 bool hasStrikethrough; // 删除线
bool hasOutline; // 显示描边 bool hasOutline; // 显示描边
Color outlineColor; // 描边颜色 Color outlineColor; // 描边颜色
double outlineWidth; // 描边线宽 float outlineWidth; // 描边线宽
LineJoin outlineJoin; // 描边线相交样式 LineJoin outlineJoin; // 描边线相交样式
public: public:
@ -574,13 +574,13 @@ public:
Color color, Color color,
Align alignment = Align::Left, Align alignment = Align::Left,
bool wrapping = false, bool wrapping = false,
double wrappingWidth = 0.0, float wrappingWidth = 0.f,
double lineSpacing = 0.0, float lineSpacing = 0.f,
bool hasUnderline = false, bool hasUnderline = false,
bool hasStrikethrough = false, bool hasStrikethrough = false,
bool hasOutline = true, bool hasOutline = true,
Color outlineColor = Color(Color::Black, 0.5), Color outlineColor = Color(Color::Black, 0.5),
double outlineWidth = 1.0, float outlineWidth = 1.f,
LineJoin outlineJoin = LineJoin::Round LineJoin outlineJoin = LineJoin::Round
); );
}; };
@ -609,7 +609,7 @@ public:
String getFontFamily() const; String getFontFamily() const;
// 获取当前字号 // 获取当前字号
double getFontSize() const; float getFontSize() const;
// 获取当前字体粗细值 // 获取当前字体粗细值
UINT getFontWeight() const; UINT getFontWeight() const;
@ -621,7 +621,7 @@ public:
Color getOutlineColor() const; Color getOutlineColor() const;
// 获取描边线宽 // 获取描边线宽
double getOutlineWidth() const; float getOutlineWidth() const;
// 获取描边线相交样式 // 获取描边线相交样式
LineJoin getOutlineJoin() const; LineJoin getOutlineJoin() const;
@ -663,7 +663,7 @@ public:
// 设置字号(默认值为 22 // 设置字号(默认值为 22
void setFontSize( void setFontSize(
double size float size
); );
// 设置字体粗细值(默认值为 Text::Font::Weight::Normal // 设置字体粗细值(默认值为 Text::Font::Weight::Normal
@ -688,12 +688,12 @@ public:
// 设置文本自动换行的宽度(默认为 0 // 设置文本自动换行的宽度(默认为 0
void setWrappingWidth( void setWrappingWidth(
double wrappingWidth float wrappingWidth
); );
// 设置行间距(默认为 0 // 设置行间距(默认为 0
void setLineSpacing( void setLineSpacing(
double lineSpacing float lineSpacing
); );
// 设置对齐方式(默认为 Align::Left // 设置对齐方式(默认为 Align::Left
@ -723,7 +723,7 @@ public:
// 设置描边线宽 // 设置描边线宽
void setOutlineWidth( void setOutlineWidth(
double outlineWidth float outlineWidth
); );
// 设置描边线相交样式 // 设置描边线相交样式

View File

@ -33,7 +33,7 @@ public:
Color getLineColor() const; Color getLineColor() const;
// 获取线条宽度 // 获取线条宽度
double getStrokeWidth() const; float getStrokeWidth() const;
// 设置填充颜色 // 设置填充颜色
void setFillColor( void setFillColor(
@ -47,7 +47,7 @@ public:
// 设置线条宽度 // 设置线条宽度
void setStrokeWidth( void setStrokeWidth(
double strokeWidth float strokeWidth
); );
// 设置样式 // 设置样式
@ -117,33 +117,33 @@ public:
explicit RoundRectShape( explicit RoundRectShape(
Size size, /* 宽度和高度 */ Size size, /* 宽度和高度 */
double radiusX, /* Ô˛˝Ç°ëžś */ float radiusX, /* Ô²½Ç°ë¾¶ */
double radiusY /* Ô˛˝Ç°ëžś */ float radiusY /* Ô²½Ç°ë¾¶ */
); );
explicit RoundRectShape( explicit RoundRectShape(
Point topLeft, /* 左上角坐标 */ Point topLeft, /* 左上角坐标 */
Size size, /* 宽度和高度 */ Size size, /* 宽度和高度 */
double radiusX, /* Ô˛˝Ç°ëžś */ float radiusX, /* Ô²½Ç°ë¾¶ */
double radiusY /* Ô˛˝Ç°ëžś */ float radiusY /* Ô²½Ç°ë¾¶ */
); );
virtual ~RoundRectShape(); virtual ~RoundRectShape();
// 获取圆角半径 // 获取圆角半径
double getRadiusX() const; float getRadiusX() const;
// 获取圆角半径 // 获取圆角半径
double getRadiusY() const; float getRadiusY() const;
// 设置圆角半径 // 设置圆角半径
virtual void setRadiusX( virtual void setRadiusX(
double radiusX float radiusX
); );
// 设置圆角半径 // 设置圆角半径
virtual void setRadiusY( virtual void setRadiusY(
double radiusY float radiusY
); );
protected: protected:
@ -169,22 +169,22 @@ public:
CircleShape(); CircleShape();
explicit CircleShape( explicit CircleShape(
double radius /* °ëžś */ float radius /* °ë¾¶ */
); );
explicit CircleShape( explicit CircleShape(
Point center, /* 圆心坐标 */ Point center, /* 圆心坐标 */
double radius /* °ëžś */ float radius /* °ë¾¶ */
); );
virtual ~CircleShape(); virtual ~CircleShape();
// 获取半径 // 获取半径
double getRadius() const; float getRadius() const;
// 设置半径 // 设置半径
virtual void setRadius( virtual void setRadius(
double radius float radius
); );
protected: protected:
@ -209,32 +209,32 @@ public:
EllipseShape(); EllipseShape();
explicit EllipseShape( explicit EllipseShape(
double radiusX, /* şáÖá°ëžś */ float radiusX, /* ºáÖá°ë¾¶ */
double radiusY /* ×ÝÖá°ëžś */ float radiusY /* ×ÝÖá°ë¾¶ */
); );
explicit EllipseShape( explicit EllipseShape(
Point center, /* 圆心坐标 */ Point center, /* 圆心坐标 */
double radiusX, /* şáÖá°ëžś */ float radiusX, /* ºáÖá°ë¾¶ */
double radiusY /* ×ÝÖá°ëžś */ float radiusY /* ×ÝÖá°ë¾¶ */
); );
virtual ~EllipseShape(); virtual ~EllipseShape();
// 获取横轴半径 // 获取横轴半径
double getRadiusX() const; float getRadiusX() const;
// 获取纵轴半径 // 获取纵轴半径
double getRadiusY() const; float getRadiusY() const;
// 设置横轴半径 // 设置横轴半径
virtual void setRadiusX( virtual void setRadiusX(
double radiusX float radiusX
); );
// 设置纵轴半径 // 设置纵轴半径
virtual void setRadiusY( virtual void setRadiusY(
double radiusY float radiusY
); );
protected: protected:

View File

@ -17,13 +17,13 @@ public:
} }
// 取得范围内的一个浮点数随机数 // 取得范围内的一个浮点数随机数
static inline double range(float min, float max) static inline float range(float min, float max)
{ {
return e2d::Random::__randomReal(min, max); return e2d::Random::__randomReal(min, max);
} }
// 取得范围内的一个浮点数随机数 // 取得范围内的一个浮点数随机数
static inline double range(double min, double max) static inline double range(double min, double max)
{ {
return e2d::Random::__randomReal(min, max); return e2d::Random::__randomReal(min, max);
} }
@ -99,7 +99,7 @@ public:
// 设置音量 // 设置音量
bool setVolume( bool setVolume(
double volume float volume
); );
// 设置播放结束时的执行函数 // 设置播放结束时的执行函数
@ -222,11 +222,11 @@ public:
); );
// 获取音量 // 获取音量
double getVolume(); float getVolume();
// 设置音量 // 设置音量
void setVolume( void setVolume(
double volume /* 音量范围为 -224 ~ 2240 是静音1 是正常音量 */ float volume /* 音量范围为 -224 ~ 2240 是静音1 是正常音量 */
); );
// 暂停所有音乐 // 暂停所有音乐
@ -277,7 +277,7 @@ public:
explicit Task( explicit Task(
const Function& func, /* 执行函数 */ const Function& func, /* 执行函数 */
double delay, /* 时间间隔(秒) */ float delay, /* 时间间隔(秒) */
int times = -1, /* 执行次数(设 -1 为永久执行) */ int times = -1, /* 执行次数(设 -1 为永久执行) */
const String& name = L"" /* 任务名称 */ const String& name = L"" /* 任务名称 */
); );
@ -308,8 +308,8 @@ private:
bool _stopped; bool _stopped;
int _runTimes; int _runTimes;
int _totalTimes; int _totalTimes;
double _delay; float _delay;
double _lastTime; float _lastTime;
String _name; String _name;
Function _callback; Function _callback;
}; };
@ -391,9 +391,9 @@ public:
int value /* 数据 */ int value /* 数据 */
); );
// 保存 double 类型的值 // 保存 float 类型的值
void saveDouble( void saveDouble(
double value /* 数据 */ float value /* 数据 */
); );
// 保存 bool 类型的值 // 保存 bool 类型的值
@ -412,10 +412,10 @@ public:
int defaultValue /* 默认值 */ int defaultValue /* 默认值 */
); );
// 获取 double 类型的值 // 获取 float 类型的值
// (若不存在则返回 defaultValue 参数的值) // (若不存在则返回 defaultValue 参数的值)
double getDouble( float getDouble(
double defaultValue /* 默认值 */ float defaultValue /* 默认值 */
); );
// 获取 bool 类型的值 // 获取 bool 类型的值

View File

@ -15,7 +15,7 @@ class Transition :
friend class SceneManager; friend class SceneManager;
public: public:
explicit Transition(double duration); explicit Transition(float duration);
virtual ~Transition(); virtual ~Transition();
@ -46,8 +46,8 @@ protected:
protected: protected:
bool _end; bool _end;
double _duration; float _duration;
double _delta; float _delta;
Duration _last; Duration _last;
Size _windowSize; Size _windowSize;
Scene * _outScene; Scene * _outScene;
@ -65,7 +65,7 @@ class FadeTransition :
{ {
public: public:
explicit FadeTransition( explicit FadeTransition(
double duration /* 动画持续时长 */ float duration /* 动画持续时长 */
); );
protected: protected:
@ -87,7 +87,7 @@ class EmergeTransition :
{ {
public: public:
explicit EmergeTransition( explicit EmergeTransition(
double duration /* 浮现动画持续时长 */ float duration /* 浮现动画持续时长 */
); );
protected: protected:
@ -109,7 +109,7 @@ class BoxTransition :
{ {
public: public:
explicit BoxTransition( explicit BoxTransition(
double duration /* 动画持续时长 */ float duration /* 动画持续时长 */
); );
protected: protected:
@ -131,7 +131,7 @@ class MoveTransition :
{ {
public: public:
explicit MoveTransition( explicit MoveTransition(
double moveDuration, /* 场景移动动画持续时长 */ float moveDuration, /* 场景移动动画持续时长 */
Direction direction = Direction::Left /* 场景移动方向 */ Direction direction = Direction::Left /* 场景移动方向 */
); );