mirror of https://github.com/axmolengine/axmol.git
Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into develop_label_fixs
Conflicts: cocos/2d/CCLabel.cpp
This commit is contained in:
commit
1247760d95
|
@ -1 +1 @@
|
|||
819b72559f8be48c41958b0afb4c6513207b453a
|
||||
8141cfdd7d973fa5a4c189a72c2fd6cac8eb95ae
|
|
@ -590,7 +590,7 @@ void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners, c
|
|||
// priority < 0
|
||||
if (fixedPriorityListeners)
|
||||
{
|
||||
CCASSERT(listeners->getGt0Index() <= fixedPriorityListeners->size(), "Out of range exception!");
|
||||
CCASSERT(listeners->getGt0Index() <= static_cast<ssize_t>(fixedPriorityListeners->size()), "Out of range exception!");
|
||||
|
||||
if (!fixedPriorityListeners->empty())
|
||||
{
|
||||
|
|
|
@ -231,6 +231,8 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
|
|||
auto pixelFormat = fontTTf->getOutlineSize() > 0 ? Texture2D::PixelFormat::AI88 : Texture2D::PixelFormat::A8;
|
||||
|
||||
bool existNewLetter = false;
|
||||
int bottomHeight = _commonLineHeight - _fontAscender;
|
||||
|
||||
for (int i = 0; i < length; ++i)
|
||||
{
|
||||
auto outIterator = _fontLetterDefinitions.find(utf16String[i]);
|
||||
|
@ -248,6 +250,7 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
|
|||
tempDef.height = tempRect.size.height + _letterPadding;
|
||||
tempDef.offsetX = tempRect.origin.x + offsetAdjust;
|
||||
tempDef.offsetY = _fontAscender + tempRect.origin.y - offsetAdjust;
|
||||
tempDef.clipBottom = bottomHeight - (tempDef.height + tempRect.origin.y + offsetAdjust);
|
||||
|
||||
if (_currentPageOrigX + tempDef.width > CacheTextureWidth)
|
||||
{
|
||||
|
@ -290,6 +293,7 @@ bool FontAtlas::prepareLetterDefinitions(unsigned short *utf16String)
|
|||
tempDef.offsetX = 0;
|
||||
tempDef.offsetY = 0;
|
||||
tempDef.textureID = 0;
|
||||
tempDef.clipBottom = 0;
|
||||
_currentPageOrigX += 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,8 @@ struct FontLetterDefinition
|
|||
int textureID;
|
||||
bool validDefinition;
|
||||
int xAdvance;
|
||||
|
||||
int clipBottom;
|
||||
};
|
||||
|
||||
class CC_DLL FontAtlas : public Ref
|
||||
|
|
|
@ -388,7 +388,7 @@ unsigned char * makeDistanceMap( unsigned char *img, long width, long height)
|
|||
double * data = (double *) calloc( pixelAmount, sizeof(double) );
|
||||
double * outside = (double *) calloc( pixelAmount, sizeof(double) );
|
||||
double * inside = (double *) calloc( pixelAmount, sizeof(double) );
|
||||
unsigned int i,j;
|
||||
long i,j;
|
||||
|
||||
// Convert img into double (data) rescale image levels between 0 and 1
|
||||
long outWidth = width + 2 * FontFreeType::DistanceMapSpread;
|
||||
|
|
|
@ -341,7 +341,9 @@ void Label::reset()
|
|||
_textColor = Color4B::WHITE;
|
||||
_textColorF = Color4F::WHITE;
|
||||
setColor(Color3B::WHITE);
|
||||
|
||||
_shadowEnabled = false;
|
||||
_clipEnabled = false;
|
||||
}
|
||||
|
||||
void Label::updateShaderProgram()
|
||||
|
|
|
@ -217,6 +217,10 @@ public:
|
|||
|
||||
virtual Sprite * getLetter(int lettetIndex);
|
||||
|
||||
/** clip upper and lower margin for reduce height of label.
|
||||
*/
|
||||
void setClipMarginEnabled(bool clipEnabled) { _clipEnabled = clipEnabled; }
|
||||
bool isClipMarginEnabled() const { return _clipEnabled; }
|
||||
// font related stuff
|
||||
int getCommonLineHeight() const;
|
||||
|
||||
|
@ -370,6 +374,8 @@ protected:
|
|||
Color4B _textColor;
|
||||
Color4F _textColorF;
|
||||
|
||||
bool _clipEnabled;
|
||||
|
||||
private:
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(Label);
|
||||
|
||||
|
|
|
@ -322,6 +322,16 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
|
|||
Point letterPosition;
|
||||
const auto& kernings = theLabel->_horizontalKernings;
|
||||
|
||||
float clipTop = 0;
|
||||
float clipBottom = 0;
|
||||
int lineIndex = 0;
|
||||
bool lineStart = true;
|
||||
bool clip = false;
|
||||
if (theLabel->_currentLabelType == Label::LabelType::TTF && theLabel->_clipEnabled)
|
||||
{
|
||||
clip = true;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < stringLen; i++)
|
||||
{
|
||||
unsigned short c = strWhole[i];
|
||||
|
@ -340,6 +350,7 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
|
|||
|
||||
if (c == '\n')
|
||||
{
|
||||
lineIndex++;
|
||||
nextFontPositionX = 0;
|
||||
nextFontPositionY -= theLabel->_commonLineHeight;
|
||||
|
||||
|
@ -347,8 +358,30 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
|
|||
if(nextFontPositionY < theLabel->_commonLineHeight)
|
||||
break;
|
||||
|
||||
lineStart = true;
|
||||
continue;
|
||||
}
|
||||
else if (clip && tempDefinition.height > 0.0f)
|
||||
{
|
||||
if (lineStart)
|
||||
{
|
||||
if (lineIndex == 0)
|
||||
{
|
||||
clipTop = charYOffset;
|
||||
}
|
||||
lineStart = false;
|
||||
clipBottom = tempDefinition.clipBottom;
|
||||
}
|
||||
else if(tempDefinition.clipBottom < clipBottom)
|
||||
{
|
||||
clipBottom = tempDefinition.clipBottom;
|
||||
}
|
||||
|
||||
if (lineIndex == 0 && charYOffset < clipTop)
|
||||
{
|
||||
clipTop = charYOffset;
|
||||
}
|
||||
}
|
||||
|
||||
letterPosition.x = (nextFontPositionX + charXOffset + kernings[i]) / contentScaleFactor;
|
||||
letterPosition.y = (nextFontPositionY - charYOffset) / contentScaleFactor;
|
||||
|
@ -382,11 +415,26 @@ bool LabelTextFormatter::createStringSprites(Label *theLabel)
|
|||
}
|
||||
|
||||
tmpSize.height = totalHeight;
|
||||
|
||||
if (theLabel->_labelHeight > 0)
|
||||
{
|
||||
tmpSize.height = theLabel->_labelHeight * contentScaleFactor;
|
||||
}
|
||||
|
||||
if (clip)
|
||||
{
|
||||
int clipTotal = (clipTop + clipBottom) / contentScaleFactor;
|
||||
tmpSize.height -= clipTotal * contentScaleFactor;
|
||||
clipBottom /= contentScaleFactor;
|
||||
|
||||
for (int i = 0; i < theLabel->_limitShowCount; i++)
|
||||
{
|
||||
theLabel->_lettersInfo[i].position.y -= clipBottom;
|
||||
}
|
||||
}
|
||||
|
||||
theLabel->setContentSize(CC_SIZE_PIXELS_TO_POINTS(tmpSize));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -492,7 +492,7 @@ void TMXLayer::setTileGID(uint32_t gid, const Point& pos, TMXTileFlags flags)
|
|||
{
|
||||
CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position");
|
||||
CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released");
|
||||
CCASSERT(gid == 0 || gid >= _tileSet->_firstGid, "TMXLayer: invalid gid" );
|
||||
CCASSERT(gid == 0 || (int)gid >= _tileSet->_firstGid, "TMXLayer: invalid gid" );
|
||||
|
||||
TMXTileFlags currentFlags;
|
||||
uint32_t currentGID = getTileGIDAt(pos, ¤tFlags);
|
||||
|
|
|
@ -1203,6 +1203,9 @@ void Texture2D::generateMipmap()
|
|||
GL::bindTexture2D( _name );
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
_hasMipmaps = true;
|
||||
#if CC_ENABLE_CACHE_TEXTURE_DATA
|
||||
VolatileTextureMgr::setHasMipmaps(this, _hasMipmaps);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Texture2D::hasMipmaps() const
|
||||
|
|
|
@ -635,6 +635,12 @@ void VolatileTextureMgr::addStringTexture(Texture2D *tt, const char* text, const
|
|||
vt->_fontDefinition = fontDefinition;
|
||||
}
|
||||
|
||||
void VolatileTextureMgr::setHasMipmaps(Texture2D *t, bool hasMipmaps)
|
||||
{
|
||||
VolatileTexture *vt = findVolotileTexture(t);
|
||||
vt->_hasMipmaps = hasMipmaps;
|
||||
}
|
||||
|
||||
void VolatileTextureMgr::setTexParameters(Texture2D *t, const Texture2D::TexParams &texParams)
|
||||
{
|
||||
VolatileTexture *vt = findVolotileTexture(t);
|
||||
|
@ -717,6 +723,9 @@ void VolatileTextureMgr::reloadAllTextures()
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (vt->_hasMipmaps) {
|
||||
vt->_texture->generateMipmap();
|
||||
}
|
||||
vt->_texture->setTexParameters(vt->_texParams);
|
||||
}
|
||||
|
||||
|
|
|
@ -251,6 +251,7 @@ protected:
|
|||
|
||||
std::string _fileName;
|
||||
|
||||
bool _hasMipmaps;
|
||||
Texture2D::TexParams _texParams;
|
||||
std::string _text;
|
||||
FontDefinition _fontDefinition;
|
||||
|
@ -264,6 +265,7 @@ public:
|
|||
static void addDataTexture(Texture2D *tt, void* data, int dataLen, Texture2D::PixelFormat pixelFormat, const Size& contentSize);
|
||||
static void addImage(Texture2D *tt, Image *image);
|
||||
|
||||
static void setHasMipmaps(Texture2D *t, bool hasMipmaps);
|
||||
static void setTexParameters(Texture2D *t, const Texture2D::TexParams &texParams);
|
||||
static void removeTexture(Texture2D *t);
|
||||
static void reloadAllTextures();
|
||||
|
|
|
@ -241,7 +241,7 @@ void ActionNode::insertFrame(int index, ActionFrame* frame)
|
|||
return;
|
||||
}
|
||||
int frameType = frame->getFrameType();
|
||||
if(frameType < _frameArray.size())
|
||||
if(frameType < (int)_frameArray.size())
|
||||
{
|
||||
auto cArray = _frameArray.at(frameType);
|
||||
cArray->insert(index, frame);
|
||||
|
@ -256,7 +256,7 @@ void ActionNode::addFrame(ActionFrame* frame)
|
|||
}
|
||||
int frameType = frame->getFrameType();
|
||||
|
||||
if(frameType < _frameArray.size())
|
||||
if(frameType < (int)_frameArray.size())
|
||||
{
|
||||
auto cArray = _frameArray.at(frameType);
|
||||
cArray->pushBack(frame);
|
||||
|
@ -270,7 +270,7 @@ void ActionNode::deleteFrame(ActionFrame* frame)
|
|||
return;
|
||||
}
|
||||
int frameType = frame->getFrameType();
|
||||
if(frameType < _frameArray.size())
|
||||
if(frameType < (int)_frameArray.size())
|
||||
{
|
||||
auto cArray = _frameArray.at(frameType);
|
||||
cArray->eraseObject(frame);
|
||||
|
|
|
@ -126,8 +126,8 @@ void Skin::setSkinData(const BaseData &var)
|
|||
|
||||
setScaleX(_skinData.scaleX);
|
||||
setScaleY(_skinData.scaleY);
|
||||
setRotationX(CC_RADIANS_TO_DEGREES(_skinData.skewX));
|
||||
setRotationY(CC_RADIANS_TO_DEGREES(-_skinData.skewY));
|
||||
setRotationSkewX(CC_RADIANS_TO_DEGREES(_skinData.skewX));
|
||||
setRotationSkewY(CC_RADIANS_TO_DEGREES(-_skinData.skewY));
|
||||
setPosition(Point(_skinData.x, _skinData.y));
|
||||
|
||||
_skinTransform = getNodeToParentTransform();
|
||||
|
|
|
@ -187,10 +187,11 @@ void WsThreadHelper::update(float dt)
|
|||
WsMessage *msg = nullptr;
|
||||
|
||||
// Returns quickly if no message
|
||||
std::lock_guard<std::mutex> lk(_UIWsMessageQueueMutex);
|
||||
_UIWsMessageQueueMutex.lock();
|
||||
|
||||
if (0 == _UIWsMessageQueue->size())
|
||||
{
|
||||
_UIWsMessageQueueMutex.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -198,6 +199,8 @@ void WsThreadHelper::update(float dt)
|
|||
msg = *(_UIWsMessageQueue->begin());
|
||||
_UIWsMessageQueue->pop_front();
|
||||
|
||||
_UIWsMessageQueueMutex.unlock();
|
||||
|
||||
if (_ws)
|
||||
{
|
||||
_ws->onUIThreadReceiveMessage(msg);
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
-- @module Label
|
||||
-- @extend SpriteBatchNode,LabelProtocol,
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Label] isClipMarginEnabled
|
||||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Label] enableShadow
|
||||
-- @param self
|
||||
|
@ -57,6 +62,11 @@
|
|||
-- @param self
|
||||
-- @return TextHAlignment#TextHAlignment ret (return value: cc.TextHAlignment)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Label] setClipMarginEnabled
|
||||
-- @param self
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Label] setString
|
||||
-- @param self
|
||||
|
|
|
@ -52,6 +52,11 @@
|
|||
-- @param self
|
||||
-- @return RichText#RichText ret (return value: ccui.RichText)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RichText] getDescription
|
||||
-- @param self
|
||||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RichText] RichText
|
||||
-- @param self
|
||||
|
|
|
@ -187,57 +187,21 @@
|
|||
-- @param #int int
|
||||
-- @param #int int
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] getChildByName
|
||||
-- @param self
|
||||
-- @param #char char
|
||||
-- @return Widget#Widget ret (return value: ccui.Widget)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] getDescription
|
||||
-- @param self
|
||||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] removeAllChildren
|
||||
-- @function [parent=#ScrollView] update
|
||||
-- @param self
|
||||
|
||||
--------------------------------
|
||||
-- overload function: getChildren()
|
||||
--
|
||||
-- overload function: getChildren()
|
||||
--
|
||||
-- @function [parent=#ScrollView] getChildren
|
||||
-- @param self
|
||||
-- @return array_table#array_table ret (retunr value: array_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] getNodes
|
||||
-- @param self
|
||||
-- @return array_table#array_table ret (return value: array_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] getChildByTag
|
||||
-- @param self
|
||||
-- @param #int int
|
||||
-- @return Node#Node ret (return value: cc.Node)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] removeNode
|
||||
-- @param self
|
||||
-- @param #cc.Node node
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] removeNodeByTag
|
||||
-- @param self
|
||||
-- @param #int int
|
||||
|
||||
--------------------------------
|
||||
-- overload function: addNode(cc.Node, int)
|
||||
--
|
||||
-- overload function: addNode(cc.Node)
|
||||
--
|
||||
-- overload function: addNode(cc.Node, int, int)
|
||||
--
|
||||
-- @function [parent=#ScrollView] addNode
|
||||
-- @param self
|
||||
-- @param #cc.Node node
|
||||
-- @param #int int
|
||||
-- @param #int int
|
||||
-- @param #float float
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] getLayoutType
|
||||
|
@ -250,24 +214,7 @@
|
|||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] update
|
||||
-- @param self
|
||||
-- @param #float float
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] getNodeByTag
|
||||
-- @param self
|
||||
-- @param #int int
|
||||
-- @return Node#Node ret (return value: cc.Node)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] getChildByName
|
||||
-- @param self
|
||||
-- @param #char char
|
||||
-- @return Widget#Widget ret (return value: ccui.Widget)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] removeAllNodes
|
||||
-- @function [parent=#ScrollView] removeAllChildren
|
||||
-- @param self
|
||||
|
||||
--------------------------------
|
||||
|
@ -276,6 +223,21 @@
|
|||
-- @param #cc.Node node
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- overload function: getChildren()
|
||||
--
|
||||
-- overload function: getChildren()
|
||||
--
|
||||
-- @function [parent=#ScrollView] getChildren
|
||||
-- @param self
|
||||
-- @return array_table#array_table ret (retunr value: array_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] getChildByTag
|
||||
-- @param self
|
||||
-- @param #int int
|
||||
-- @return Node#Node ret (return value: cc.Node)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ScrollView] getChildrenCount
|
||||
-- @param self
|
||||
|
|
|
@ -1,18 +1,13 @@
|
|||
|
||||
--------------------------------
|
||||
-- @module Widget
|
||||
-- @extend Node
|
||||
-- @extend ProtectedNode
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] setSizePercent
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] isFlippedX
|
||||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getCustomSize
|
||||
-- @param self
|
||||
|
@ -29,10 +24,9 @@
|
|||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getNodeByTag
|
||||
-- @function [parent=#Widget] getLeftInParent
|
||||
-- @param self
|
||||
-- @param #int int
|
||||
-- @return Node#Node ret (return value: cc.Node)
|
||||
-- @return float#float ret (return value: float)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getTouchEndPos
|
||||
|
@ -44,11 +38,6 @@
|
|||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getNodes
|
||||
-- @param self
|
||||
-- @return array_table#array_table ret (return value: array_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getLayoutSize
|
||||
-- @param self
|
||||
|
@ -69,15 +58,6 @@
|
|||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- overload function: updateSizeAndPosition(size_table)
|
||||
--
|
||||
-- overload function: updateSizeAndPosition()
|
||||
--
|
||||
-- @function [parent=#Widget] updateSizeAndPosition
|
||||
-- @param self
|
||||
-- @param #size_table size
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getBottomInParent
|
||||
-- @param self
|
||||
|
@ -100,9 +80,9 @@
|
|||
-- @return PositionType#PositionType ret (return value: ccui.PositionType)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] setName
|
||||
-- @function [parent=#Widget] getWidgetType
|
||||
-- @param self
|
||||
-- @param #char char
|
||||
-- @return WidgetType#WidgetType ret (return value: ccui.WidgetType)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getChildByName
|
||||
|
@ -116,9 +96,9 @@
|
|||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] removeNodeByTag
|
||||
-- @function [parent=#Widget] isFocused
|
||||
-- @param self
|
||||
-- @param #int int
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] isTouchEnabled
|
||||
|
@ -175,17 +155,9 @@
|
|||
-- @param #ccui.BrightStyle brightstyle
|
||||
|
||||
--------------------------------
|
||||
-- overload function: addNode(cc.Node, int)
|
||||
--
|
||||
-- overload function: addNode(cc.Node)
|
||||
--
|
||||
-- overload function: addNode(cc.Node, int, int)
|
||||
--
|
||||
-- @function [parent=#Widget] addNode
|
||||
-- @function [parent=#Widget] setName
|
||||
-- @param self
|
||||
-- @param #cc.Node node
|
||||
-- @param #int int
|
||||
-- @param #int int
|
||||
-- @param #char char
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] setLayoutParameter
|
||||
|
@ -202,21 +174,11 @@
|
|||
-- @param self
|
||||
-- @return point_table#point_table ret (return value: point_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getLeftInParent
|
||||
-- @param self
|
||||
-- @return float#float ret (return value: float)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] setActionTag
|
||||
-- @param self
|
||||
-- @param #int int
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] ignoreContentAdaptWithSize
|
||||
-- @param self
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] isBright
|
||||
-- @param self
|
||||
|
@ -234,9 +196,13 @@
|
|||
-- @return float#float ret (return value: float)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getWidgetType
|
||||
-- overload function: updateSizeAndPosition(size_table)
|
||||
--
|
||||
-- overload function: updateSizeAndPosition()
|
||||
--
|
||||
-- @function [parent=#Widget] updateSizeAndPosition
|
||||
-- @param self
|
||||
-- @return WidgetType#WidgetType ret (return value: ccui.WidgetType)
|
||||
-- @param #size_table size
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getSize
|
||||
|
@ -254,13 +220,9 @@
|
|||
-- @return SizeType#SizeType ret (return value: ccui.SizeType)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] removeNode
|
||||
-- @param self
|
||||
-- @param #cc.Node node
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] removeAllNodes
|
||||
-- @function [parent=#Widget] ignoreContentAdaptWithSize
|
||||
-- @param self
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getPositionPercent
|
||||
|
@ -274,7 +236,7 @@
|
|||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] isFocused
|
||||
-- @function [parent=#Widget] isFlippedX
|
||||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
|
@ -310,72 +272,11 @@
|
|||
-- @param self
|
||||
-- @return Widget#Widget ret (return value: ccui.Widget)
|
||||
|
||||
--------------------------------
|
||||
-- overload function: addChild(cc.Node, int)
|
||||
--
|
||||
-- overload function: addChild(cc.Node)
|
||||
--
|
||||
-- overload function: addChild(cc.Node, int, int)
|
||||
--
|
||||
-- @function [parent=#Widget] addChild
|
||||
-- @param self
|
||||
-- @param #cc.Node node
|
||||
-- @param #int int
|
||||
-- @param #int int
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] setColor
|
||||
-- @param self
|
||||
-- @param #color3B_table color3b
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] removeFromParent
|
||||
-- @param self
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] removeAllChildrenWithCleanup
|
||||
-- @param self
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] removeAllChildren
|
||||
-- @param self
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] sortAllChildren
|
||||
-- @param self
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] removeChild
|
||||
-- @param self
|
||||
-- @param #cc.Node node
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- overload function: getChildren()
|
||||
--
|
||||
-- overload function: getChildren()
|
||||
--
|
||||
-- @function [parent=#Widget] getChildren
|
||||
-- @param self
|
||||
-- @return array_table#array_table ret (retunr value: array_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getDescription
|
||||
-- @param self
|
||||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getChildByTag
|
||||
-- @param self
|
||||
-- @param #int int
|
||||
-- @return Node#Node ret (return value: cc.Node)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] removeFromParentAndCleanup
|
||||
-- @param self
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getColor
|
||||
-- @param self
|
||||
|
@ -386,26 +287,20 @@
|
|||
-- @param self
|
||||
-- @param #unsigned char char
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] setPosition
|
||||
-- @param self
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] removeChildByTag
|
||||
-- @param self
|
||||
-- @param #int int
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getOpacity
|
||||
-- @param self
|
||||
-- @return unsigned char#unsigned char ret (return value: unsigned char)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getChildrenCount
|
||||
-- @function [parent=#Widget] setPosition
|
||||
-- @param self
|
||||
-- @return long#long ret (return value: long)
|
||||
-- @param #point_table point
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] getDescription
|
||||
-- @param self
|
||||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Widget] Widget
|
||||
|
|
|
@ -1 +1 @@
|
|||
83d9fece450a67211518c287e9ecf99ce122c142
|
||||
bb331bf4e55b4ca2f5b12c75e6c3e638ae3367d0
|
|
@ -1544,6 +1544,8 @@ int register_all_cocos2dx(lua_State* tolua_S);
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
11bba6be0cebc89eb4c7195a61d021e51719468f
|
||||
19adb2eb5a08b20b670b77975f7e30c08bbac2d6
|
|
@ -362,12 +362,6 @@ int register_all_cocos2dx_ui(lua_State* tolua_S);
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -340,7 +340,7 @@ void RichText::formarRenderers()
|
|||
float newContentSizeHeight = 0.0f;
|
||||
float *maxHeights = new float[_elementRenders.size()];
|
||||
|
||||
for (ssize_t i=0; i<_elementRenders.size(); i++)
|
||||
for (size_t i=0; i<_elementRenders.size(); i++)
|
||||
{
|
||||
Vector<Node*>* row = (_elementRenders[i]);
|
||||
float maxHeight = 0.0f;
|
||||
|
@ -355,7 +355,7 @@ void RichText::formarRenderers()
|
|||
|
||||
|
||||
float nextPosY = _customSize.height;
|
||||
for (ssize_t i=0; i<_elementRenders.size(); i++)
|
||||
for (size_t i=0; i<_elementRenders.size(); i++)
|
||||
{
|
||||
Vector<Node*>* row = (_elementRenders[i]);
|
||||
float nextPosX = 0.0f;
|
||||
|
@ -375,7 +375,7 @@ void RichText::formarRenderers()
|
|||
}
|
||||
|
||||
size_t length = _elementRenders.size();
|
||||
for (ssize_t i = 0; i<length; i++)
|
||||
for (size_t i = 0; i<length; i++)
|
||||
{
|
||||
Vector<Node*>* l = _elementRenders[i];
|
||||
l->clear();
|
||||
|
|
|
@ -23,9 +23,7 @@
|
|||
#define CHIPMUNK_HEADER
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifndef _USE_MATH_DEFINES
|
||||
#define _USE_MATH_DEFINES
|
||||
#endif
|
||||
#define _USE_MATH_DEFINES
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -112,10 +110,10 @@ typedef struct cpSpace cpSpace;
|
|||
|
||||
#include "cpSpace.h"
|
||||
|
||||
// Chipmunk 6.1.5
|
||||
// Chipmunk 6.2.1
|
||||
#define CP_VERSION_MAJOR 6
|
||||
#define CP_VERSION_MINOR 1
|
||||
#define CP_VERSION_RELEASE 5
|
||||
#define CP_VERSION_MINOR 2
|
||||
#define CP_VERSION_RELEASE 1
|
||||
|
||||
/// Version string.
|
||||
extern const char *cpVersionString;
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
#define CP_HASH_COEF (3344921057ul)
|
||||
#define CP_HASH_PAIR(A, B) ((cpHashValue)(A)*CP_HASH_COEF ^ (cpHashValue)(B)*CP_HASH_COEF)
|
||||
|
||||
// TODO: Eww. Magic numbers.
|
||||
#define MAGIC_EPSILON 1e-5
|
||||
|
||||
//MARK: cpArray
|
||||
|
||||
struct cpArray {
|
||||
|
@ -43,6 +46,7 @@ cpBool cpArrayContains(cpArray *arr, void *ptr);
|
|||
|
||||
void cpArrayFreeEach(cpArray *arr, void (freeFunc)(void*));
|
||||
|
||||
|
||||
//MARK: Foreach loops
|
||||
|
||||
static inline cpConstraint *
|
||||
|
@ -69,6 +73,7 @@ cpArbiterNext(cpArbiter *node, cpBody *body)
|
|||
#define CP_BODY_FOREACH_COMPONENT(root, var)\
|
||||
for(cpBody *var = root; var; var = var->node.next)
|
||||
|
||||
|
||||
//MARK: cpHashSet
|
||||
|
||||
typedef cpBool (*cpHashSetEqlFunc)(void *ptr, void *elt);
|
||||
|
@ -90,6 +95,7 @@ void cpHashSetEach(cpHashSet *set, cpHashSetIteratorFunc func, void *data);
|
|||
typedef cpBool (*cpHashSetFilterFunc)(void *elt, void *data);
|
||||
void cpHashSetFilter(cpHashSet *set, cpHashSetFilterFunc func, void *data);
|
||||
|
||||
|
||||
//MARK: Body Functions
|
||||
|
||||
void cpBodyAddShape(cpBody *body, cpShape *shape);
|
||||
|
@ -116,7 +122,29 @@ cpShapeActive(cpShape *shape)
|
|||
return shape->prev || (shape->body && shape->body->shapeList == shape);
|
||||
}
|
||||
|
||||
int cpCollideShapes(const cpShape *a, const cpShape *b, cpContact *arr);
|
||||
int cpCollideShapes(const cpShape *a, const cpShape *b, cpCollisionID *id, cpContact *arr);
|
||||
|
||||
static inline void
|
||||
CircleSegmentQuery(cpShape *shape, cpVect center, cpFloat r, cpVect a, cpVect b, cpSegmentQueryInfo *info)
|
||||
{
|
||||
cpVect da = cpvsub(a, center);
|
||||
cpVect db = cpvsub(b, center);
|
||||
|
||||
cpFloat qa = cpvdot(da, da) - 2.0f*cpvdot(da, db) + cpvdot(db, db);
|
||||
cpFloat qb = -2.0f*cpvdot(da, da) + 2.0f*cpvdot(da, db);
|
||||
cpFloat qc = cpvdot(da, da) - r*r;
|
||||
|
||||
cpFloat det = qb*qb - 4.0f*qa*qc;
|
||||
|
||||
if(det >= 0.0f){
|
||||
cpFloat t = (-qb - cpfsqrt(det))/(2.0f*qa);
|
||||
if(0.0f<= t && t <= 1.0f){
|
||||
info->shape = shape;
|
||||
info->t = t;
|
||||
info->n = cpvnormalize(cpvlerp(da, db, t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO doesn't really need to be inline, but need a better place to put this function
|
||||
static inline cpSplittingPlane
|
||||
|
@ -135,50 +163,12 @@ cpSplittingPlaneCompare(cpSplittingPlane plane, cpVect v)
|
|||
|
||||
void cpLoopIndexes(cpVect *verts, int count, int *start, int *end);
|
||||
|
||||
static inline cpFloat
|
||||
cpPolyShapeValueOnAxis(const cpPolyShape *poly, const cpVect n, const cpFloat d)
|
||||
{
|
||||
cpVect *verts = poly->tVerts;
|
||||
cpFloat min = cpvdot(n, verts[0]);
|
||||
|
||||
for(int i=1; i<poly->numVerts; i++){
|
||||
min = cpfmin(min, cpvdot(n, verts[i]));
|
||||
}
|
||||
|
||||
return min - d;
|
||||
}
|
||||
|
||||
static inline cpBool
|
||||
cpPolyShapeContainsVert(const cpPolyShape *poly, const cpVect v)
|
||||
{
|
||||
cpSplittingPlane *planes = poly->tPlanes;
|
||||
|
||||
for(int i=0; i<poly->numVerts; i++){
|
||||
cpFloat dist = cpSplittingPlaneCompare(planes[i], v);
|
||||
if(dist > 0.0f) return cpFalse;
|
||||
}
|
||||
|
||||
return cpTrue;
|
||||
}
|
||||
|
||||
static inline cpBool
|
||||
cpPolyShapeContainsVertPartial(const cpPolyShape *poly, const cpVect v, const cpVect n)
|
||||
{
|
||||
cpSplittingPlane *planes = poly->tPlanes;
|
||||
|
||||
for(int i=0; i<poly->numVerts; i++){
|
||||
if(cpvdot(planes[i].n, n) < 0.0f) continue;
|
||||
cpFloat dist = cpSplittingPlaneCompare(planes[i], v);
|
||||
if(dist > 0.0f) return cpFalse;
|
||||
}
|
||||
|
||||
return cpTrue;
|
||||
}
|
||||
|
||||
//MARK: Spatial Index Functions
|
||||
|
||||
cpSpatialIndex *cpSpatialIndexInit(cpSpatialIndex *index, cpSpatialIndexClass *klass, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex);
|
||||
|
||||
|
||||
//MARK: Space Functions
|
||||
|
||||
extern cpCollisionHandler cpDefaultCollisionHandler;
|
||||
|
@ -221,8 +211,7 @@ cpSpaceUncacheArbiter(cpSpace *space, cpArbiter *arb)
|
|||
}
|
||||
|
||||
void cpShapeUpdateFunc(cpShape *shape, void *unused);
|
||||
void cpSpaceCollideShapes(cpShape *a, cpShape *b, cpSpace *space);
|
||||
|
||||
cpCollisionID cpSpaceCollideShapes(cpShape *a, cpShape *b, cpCollisionID id, cpSpace *space);
|
||||
|
||||
|
||||
//MARK: Arbiters
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <stdint.h>
|
||||
#include <float.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include "TargetConditionals.h"
|
||||
|
@ -45,6 +46,7 @@
|
|||
#define cpfpow pow
|
||||
#define cpffloor floor
|
||||
#define cpfceil ceil
|
||||
#define CPFLOAT_MIN DBL_MIN
|
||||
#else
|
||||
typedef float cpFloat;
|
||||
#define cpfsqrt sqrtf
|
||||
|
@ -57,6 +59,7 @@
|
|||
#define cpfpow powf
|
||||
#define cpffloor floorf
|
||||
#define cpfceil ceilf
|
||||
#define CPFLOAT_MIN FLT_MIN
|
||||
#endif
|
||||
|
||||
#ifndef INFINITY
|
||||
|
@ -135,6 +138,10 @@ static inline cpFloat cpflerpconst(cpFloat f1, cpFloat f2, cpFloat d)
|
|||
/// Hash value type.
|
||||
typedef uintptr_t cpHashValue;
|
||||
|
||||
/// Type used internally to cache colliding object info for cpCollideShapes().
|
||||
/// Should be at least 32 bits.
|
||||
typedef uint32_t cpCollisionID;
|
||||
|
||||
// Oh C, how we love to define our own boolean types to get compiler compatibility
|
||||
/// Chipmunk's boolean type.
|
||||
#ifdef CP_BOOL_TYPE
|
||||
|
|
|
@ -55,6 +55,8 @@ void cpSegmentShapeSetRadius(cpShape *shape, cpFloat radius);
|
|||
|
||||
/// Set the vertexes of a poly shape.
|
||||
void cpPolyShapeSetVerts(cpShape *shape, int numVerts, cpVect *verts, cpVect offset);
|
||||
/// Set the radius of a poly shape.
|
||||
void cpPolyShapeSetRadius(cpShape *shape, cpFloat radius);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ struct cpCollisionHandler {
|
|||
|
||||
typedef struct cpContact cpContact;
|
||||
|
||||
#define CP_MAX_CONTACTS_PER_ARBITER 4
|
||||
#define CP_MAX_CONTACTS_PER_ARBITER 2
|
||||
|
||||
/// @private
|
||||
typedef enum cpArbiterState {
|
||||
|
|
|
@ -79,6 +79,13 @@ static inline cpBB cpBBExpand(const cpBB bb, const cpVect v){
|
|||
);
|
||||
}
|
||||
|
||||
/// Returns the center of a bounding box.
|
||||
static inline cpVect
|
||||
cpBBCenter(cpBB bb)
|
||||
{
|
||||
return cpvlerp(cpv(bb.l, bb.b), cpv(bb.r, bb.t), 0.5f);
|
||||
}
|
||||
|
||||
/// Returns the area of the bounding box.
|
||||
static inline cpFloat cpBBArea(cpBB bb)
|
||||
{
|
||||
|
|
|
@ -35,6 +35,8 @@ typedef struct cpPolyShape {
|
|||
int numVerts;
|
||||
cpVect *verts, *tVerts;
|
||||
cpSplittingPlane *planes, *tPlanes;
|
||||
|
||||
cpFloat r;
|
||||
} cpPolyShape;
|
||||
|
||||
/// Allocate a polygon shape.
|
||||
|
@ -42,26 +44,38 @@ cpPolyShape* cpPolyShapeAlloc(void);
|
|||
/// Initialize a polygon shape.
|
||||
/// A convex hull will be created from the vertexes.
|
||||
cpPolyShape* cpPolyShapeInit(cpPolyShape *poly, cpBody *body, int numVerts, const cpVect *verts, cpVect offset);
|
||||
/// Initialize a polygon shape.
|
||||
/// A convex hull will be created from the vertexes.
|
||||
cpPolyShape* cpPolyShapeInit2(cpPolyShape *poly, cpBody *body, int numVerts, const cpVect *verts, cpVect offset, cpFloat radius);
|
||||
/// Allocate and initialize a polygon shape.
|
||||
/// A convex hull will be created from the vertexes.
|
||||
cpShape* cpPolyShapeNew(cpBody *body, int numVerts, cpVect *verts, cpVect offset);
|
||||
cpShape* cpPolyShapeNew(cpBody *body, int numVerts, const cpVect *verts, cpVect offset);
|
||||
/// Allocate and initialize a polygon shape.
|
||||
/// A convex hull will be created from the vertexes.
|
||||
cpShape* cpPolyShapeNew2(cpBody *body, int numVerts, const cpVect *verts, cpVect offset, cpFloat radius);
|
||||
|
||||
/// Initialize a box shaped polygon shape.
|
||||
cpPolyShape* cpBoxShapeInit(cpPolyShape *poly, cpBody *body, cpFloat width, cpFloat height);
|
||||
/// Initialize an offset box shaped polygon shape.
|
||||
cpPolyShape* cpBoxShapeInit2(cpPolyShape *poly, cpBody *body, cpBB box);
|
||||
/// Initialize an offset box shaped polygon shape.
|
||||
cpPolyShape* cpBoxShapeInit3(cpPolyShape *poly, cpBody *body, cpBB box, cpFloat radius);
|
||||
/// Allocate and initialize a box shaped polygon shape.
|
||||
cpShape* cpBoxShapeNew(cpBody *body, cpFloat width, cpFloat height);
|
||||
/// Allocate and initialize an offset box shaped polygon shape.
|
||||
cpShape* cpBoxShapeNew2(cpBody *body, cpBB box);
|
||||
/// Allocate and initialize an offset box shaped polygon shape.
|
||||
cpShape* cpBoxShapeNew3(cpBody *body, cpBB box, cpFloat radius);
|
||||
|
||||
/// Check that a set of vertexes is convex and has a clockwise winding.
|
||||
/// NOTE: Due to floating point precision issues, hulls created with cpQuickHull() are not guaranteed to validate!
|
||||
cpBool cpPolyValidate(const cpVect *verts, const int numVerts);
|
||||
|
||||
/// Get the number of verts in a polygon shape.
|
||||
int cpPolyShapeGetNumVerts(cpShape *shape);
|
||||
int cpPolyShapeGetNumVerts(const cpShape *shape);
|
||||
/// Get the @c ith vertex of a polygon shape.
|
||||
cpVect cpPolyShapeGetVert(cpShape *shape, int idx);
|
||||
cpVect cpPolyShapeGetVert(const cpShape *shape, int idx);
|
||||
/// Get the radius of a polygon shape.
|
||||
cpFloat cpPolyShapeGetRadius(const cpShape *shape);
|
||||
|
||||
/// @}
|
||||
|
|
|
@ -33,6 +33,9 @@ typedef struct cpNearestPointQueryInfo {
|
|||
cpVect p;
|
||||
/// The distance to the point. The distance is negative if the point is inside the shape.
|
||||
cpFloat d;
|
||||
/// The gradient of the signed distance function.
|
||||
/// The same as info.p/info.d, but accurate even for very small values of info.d.
|
||||
cpVect g;
|
||||
} cpNearestPointQueryInfo;
|
||||
|
||||
/// Segment query info struct.
|
||||
|
@ -218,6 +221,7 @@ cpSegmentShape* cpSegmentShapeInit(cpSegmentShape *seg, cpBody *body, cpVect a,
|
|||
/// Allocate and initialize a segment shape.
|
||||
cpShape* cpSegmentShapeNew(cpBody *body, cpVect a, cpVect b, cpFloat radius);
|
||||
|
||||
/// Let Chipmunk know about the geometry of adjacent segments to avoid colliding with endcaps.
|
||||
void cpSegmentShapeSetNeighbors(cpShape *shape, cpVect prev, cpVect next);
|
||||
|
||||
CP_DeclareShapeGetter(cpSegmentShape, cpVect, A);
|
||||
|
|
|
@ -46,7 +46,7 @@ typedef cpBB (*cpSpatialIndexBBFunc)(void *obj);
|
|||
/// Spatial index/object iterator callback function type.
|
||||
typedef void (*cpSpatialIndexIteratorFunc)(void *obj, void *data);
|
||||
/// Spatial query callback function type.
|
||||
typedef void (*cpSpatialIndexQueryFunc)(void *obj1, void *obj2, void *data);
|
||||
typedef cpCollisionID (*cpSpatialIndexQueryFunc)(void *obj1, void *obj2, cpCollisionID id, void *data);
|
||||
/// Spatial segment query callback function type.
|
||||
typedef cpFloat (*cpSpatialIndexSegmentQueryFunc)(void *obj1, void *obj2, void *data);
|
||||
|
||||
|
|
|
@ -151,13 +151,14 @@ static inline cpVect cpvlerp(const cpVect v1, const cpVect v2, const cpFloat t)
|
|||
/// Returns a normalized copy of v.
|
||||
static inline cpVect cpvnormalize(const cpVect v)
|
||||
{
|
||||
return cpvmult(v, 1.0f/cpvlength(v));
|
||||
// Neat trick I saw somewhere to avoid div/0.
|
||||
return cpvmult(v, 1.0f/(cpvlength(v) + CPFLOAT_MIN));
|
||||
}
|
||||
|
||||
/// Returns a normalized copy of v or cpvzero if v was already cpvzero. Protects against divide by zero errors.
|
||||
/// @deprecated Just an alias for cpvnormalize() now.
|
||||
static inline cpVect cpvnormalize_safe(const cpVect v)
|
||||
{
|
||||
return (v.x == 0.0f && v.y == 0.0f ? cpvzero : cpvnormalize(v));
|
||||
return cpvnormalize(v);
|
||||
}
|
||||
|
||||
/// Clamp v to length len.
|
||||
|
|
|
@ -16,7 +16,14 @@ if(BUILD_SHARED)
|
|||
set_target_properties(chipmunk PROPERTIES LINKER_LANGUAGE CXX)
|
||||
endif(MSVC)
|
||||
# set the lib's version number
|
||||
set_target_properties(chipmunk PROPERTIES VERSION 6.1.5)
|
||||
# But avoid on Android because symlinks to version numbered .so's don't work with Android's Java-side loadLibrary.
|
||||
if(NOT ANDROID)
|
||||
set_target_properties(chipmunk PROPERTIES VERSION 6.2.1)
|
||||
endif(NOT ANDROID)
|
||||
if(ANDROID)
|
||||
# need to explicitly link to the math library because the CMake/Android toolchains may not do it automatically
|
||||
target_link_libraries(chipmunk m)
|
||||
endif(ANDROID)
|
||||
install(TARGETS chipmunk RUNTIME DESTINATION lib LIBRARY DESTINATION lib)
|
||||
endif(BUILD_SHARED)
|
||||
|
||||
|
|
|
@ -83,6 +83,8 @@ cpAreaForSegment(cpVect a, cpVect b, cpFloat r)
|
|||
cpFloat
|
||||
cpMomentForPoly(cpFloat m, const int numVerts, const cpVect *verts, cpVect offset)
|
||||
{
|
||||
if(numVerts == 2) return cpMomentForSegment(m, verts[0], verts[1]);
|
||||
|
||||
cpFloat sum1 = 0.0f;
|
||||
cpFloat sum2 = 0.0f;
|
||||
for(int i=0; i<numVerts; i++){
|
||||
|
|
|
@ -37,7 +37,7 @@ preStep(cpRotaryLimitJoint *joint, cpFloat dt)
|
|||
}
|
||||
|
||||
// calculate moment of inertia coefficient.
|
||||
joint->iSum = 1.0f/(1.0f/a->i + 1.0f/b->i);
|
||||
joint->iSum = 1.0f/(a->i_inv + b->i_inv);
|
||||
|
||||
// calculate bias velocity
|
||||
cpFloat maxBias = joint->constraint.maxBias;
|
||||
|
|
|
@ -72,7 +72,10 @@ typedef struct Thread {
|
|||
Pair *next;
|
||||
} Thread;
|
||||
|
||||
struct Pair { Thread a, b; };
|
||||
struct Pair {
|
||||
Thread a, b;
|
||||
cpCollisionID id;
|
||||
};
|
||||
|
||||
//MARK: Misc Functions
|
||||
|
||||
|
@ -205,7 +208,7 @@ PairInsert(Node *a, Node *b, cpBBTree *tree)
|
|||
{
|
||||
Pair *nextA = a->PAIRS, *nextB = b->PAIRS;
|
||||
Pair *pair = PairFromPool(tree);
|
||||
Pair temp = {{NULL, a, nextA},{NULL, b, nextB}};
|
||||
Pair temp = {{NULL, a, nextA},{NULL, b, nextB}, 0};
|
||||
|
||||
a->PAIRS = b->PAIRS = pair;
|
||||
*pair = temp;
|
||||
|
@ -351,7 +354,7 @@ SubtreeQuery(Node *subtree, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, vo
|
|||
{
|
||||
if(cpBBIntersects(subtree->bb, bb)){
|
||||
if(NodeIsLeaf(subtree)){
|
||||
func(obj, subtree->obj, data);
|
||||
func(obj, subtree->obj, 0, data);
|
||||
} else {
|
||||
SubtreeQuery(subtree->A, obj, bb, func, data);
|
||||
SubtreeQuery(subtree->B, obj, bb, func, data);
|
||||
|
@ -428,7 +431,7 @@ MarkLeafQuery(Node *subtree, Node *leaf, cpBool left, MarkContext *context)
|
|||
PairInsert(leaf, subtree, context->tree);
|
||||
} else {
|
||||
if(subtree->STAMP < leaf->STAMP) PairInsert(subtree, leaf, context->tree);
|
||||
context->func(leaf->obj, subtree->obj, context->data);
|
||||
context->func(leaf->obj, subtree->obj, 0, context->data);
|
||||
}
|
||||
} else {
|
||||
MarkLeafQuery(subtree->A, leaf, left, context);
|
||||
|
@ -456,7 +459,7 @@ MarkLeaf(Node *leaf, MarkContext *context)
|
|||
Pair *pair = leaf->PAIRS;
|
||||
while(pair){
|
||||
if(leaf == pair->b.leaf){
|
||||
context->func(pair->a.leaf->obj, leaf->obj, context->data);
|
||||
pair->id = context->func(pair->a.leaf->obj, leaf->obj, pair->id, context->data);
|
||||
pair = pair->b.next;
|
||||
} else {
|
||||
pair = pair->a.next;
|
||||
|
@ -472,7 +475,7 @@ MarkSubtree(Node *subtree, MarkContext *context)
|
|||
MarkLeaf(subtree, context);
|
||||
} else {
|
||||
MarkSubtree(subtree->A, context);
|
||||
MarkSubtree(subtree->B, context);
|
||||
MarkSubtree(subtree->B, context); // TODO Force TCO here?
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -508,12 +511,12 @@ LeafUpdate(Node *leaf, cpBBTree *tree)
|
|||
leaf->STAMP = GetMasterTree(tree)->stamp;
|
||||
|
||||
return cpTrue;
|
||||
} else {
|
||||
return cpFalse;
|
||||
}
|
||||
|
||||
return cpFalse;
|
||||
}
|
||||
|
||||
static void VoidQueryFunc(void *obj1, void *obj2, void *data){}
|
||||
static cpCollisionID VoidQueryFunc(void *obj1, void *obj2, cpCollisionID id, void *data){return id;}
|
||||
|
||||
static void
|
||||
LeafAddPairs(Node *leaf, cpBBTree *tree)
|
||||
|
@ -864,17 +867,17 @@ NodeRender(Node *node, int depth)
|
|||
// glColor3f(1.0f - v, v, 0.0f);
|
||||
glLineWidth(cpfmax(5.0f - depth, 1.0f));
|
||||
glBegin(GL_LINES); {
|
||||
glVertex2F(bb.l, bb.b);
|
||||
glVertex2F(bb.l, bb.t);
|
||||
glVertex2f(bb.l, bb.b);
|
||||
glVertex2f(bb.l, bb.t);
|
||||
|
||||
glVertex2F(bb.l, bb.t);
|
||||
glVertex2F(bb.r, bb.t);
|
||||
glVertex2f(bb.l, bb.t);
|
||||
glVertex2f(bb.r, bb.t);
|
||||
|
||||
glVertex2F(bb.r, bb.t);
|
||||
glVertex2F(bb.r, bb.b);
|
||||
glVertex2f(bb.r, bb.t);
|
||||
glVertex2f(bb.r, bb.b);
|
||||
|
||||
glVertex2F(bb.r, bb.b);
|
||||
glVertex2F(bb.l, bb.b);
|
||||
glVertex2f(bb.r, bb.b);
|
||||
glVertex2f(bb.l, bb.b);
|
||||
}; glEnd();
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -47,7 +47,8 @@ cpPolyShapeTransformVerts(cpPolyShape *poly, cpVect p, cpVect rot)
|
|||
t = cpfmax(t, v.y);
|
||||
}
|
||||
|
||||
return cpBBNew(l, b, r, t);
|
||||
cpFloat radius = poly->r;
|
||||
return cpBBNew(l - radius, b - radius, r + radius, t + radius);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -84,10 +85,12 @@ cpPolyShapeNearestPointQuery(cpPolyShape *poly, cpVect p, cpNearestPointQueryInf
|
|||
int count = poly->numVerts;
|
||||
cpSplittingPlane *planes = poly->tPlanes;
|
||||
cpVect *verts = poly->tVerts;
|
||||
cpFloat r = poly->r;
|
||||
|
||||
cpVect v0 = verts[count - 1];
|
||||
cpFloat minDist = INFINITY;
|
||||
cpVect closestPoint = cpvzero;
|
||||
cpVect closestNormal = cpvzero;
|
||||
cpBool outside = cpFalse;
|
||||
|
||||
for(int i=0; i<count; i++){
|
||||
|
@ -100,14 +103,21 @@ cpPolyShapeNearestPointQuery(cpPolyShape *poly, cpVect p, cpNearestPointQueryInf
|
|||
if(dist < minDist){
|
||||
minDist = dist;
|
||||
closestPoint = closest;
|
||||
closestNormal = planes[i].n;
|
||||
}
|
||||
|
||||
v0 = v1;
|
||||
}
|
||||
|
||||
cpFloat dist = (outside ? minDist : -minDist);
|
||||
cpVect g = cpvmult(cpvsub(p, closestPoint), 1.0f/dist);
|
||||
|
||||
info->shape = (cpShape *)poly;
|
||||
info->p = closestPoint; // TODO div/0
|
||||
info->d = (outside ? minDist : -minDist);
|
||||
info->p = cpvadd(closestPoint, cpvmult(g, r));
|
||||
info->d = dist - r;
|
||||
|
||||
// Use the normal of the closest segment if the distance is small.
|
||||
info->g = (minDist > MAGIC_EPSILON ? g : closestNormal);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -116,20 +126,22 @@ cpPolyShapeSegmentQuery(cpPolyShape *poly, cpVect a, cpVect b, cpSegmentQueryInf
|
|||
cpSplittingPlane *axes = poly->tPlanes;
|
||||
cpVect *verts = poly->tVerts;
|
||||
int numVerts = poly->numVerts;
|
||||
cpFloat r = poly->r;
|
||||
|
||||
for(int i=0; i<numVerts; i++){
|
||||
cpVect n = axes[i].n;
|
||||
cpFloat an = cpvdot(a, n);
|
||||
if(axes[i].d > an) continue;
|
||||
cpFloat d = axes[i].d + r - an;
|
||||
if(d > 0.0f) continue;
|
||||
|
||||
cpFloat bn = cpvdot(b, n);
|
||||
cpFloat t = (axes[i].d - an)/(bn - an);
|
||||
cpFloat t = d/(bn - an);
|
||||
if(t < 0.0f || 1.0f < t) continue;
|
||||
|
||||
cpVect point = cpvlerp(a, b, t);
|
||||
cpFloat dt = -cpvcross(n, point);
|
||||
cpFloat dtMin = -cpvcross(n, verts[i]);
|
||||
cpFloat dtMax = -cpvcross(n, verts[(i+1)%numVerts]);
|
||||
cpFloat dtMin = -cpvcross(n, verts[(i - 1 + numVerts)%numVerts]);
|
||||
cpFloat dtMax = -cpvcross(n, verts[i]);
|
||||
|
||||
if(dtMin <= dt && dt <= dtMax){
|
||||
info->shape = (cpShape *)poly;
|
||||
|
@ -137,6 +149,15 @@ cpPolyShapeSegmentQuery(cpPolyShape *poly, cpVect a, cpVect b, cpSegmentQueryInf
|
|||
info->n = n;
|
||||
}
|
||||
}
|
||||
|
||||
// Also check against the beveled vertexes.
|
||||
if(r > 0.0f){
|
||||
for(int i=0; i<numVerts; i++){
|
||||
cpSegmentQueryInfo circle_info = {NULL, 1.0f, cpvzero};
|
||||
CircleSegmentQuery(&poly->shape, verts[i], r, a, b, &circle_info);
|
||||
if(circle_info.t < info->t) (*info) = circle_info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const cpShapeClass polyClass = {
|
||||
|
@ -164,14 +185,14 @@ cpPolyValidate(const cpVect *verts, const int numVerts)
|
|||
}
|
||||
|
||||
int
|
||||
cpPolyShapeGetNumVerts(cpShape *shape)
|
||||
cpPolyShapeGetNumVerts(const cpShape *shape)
|
||||
{
|
||||
cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape.");
|
||||
return ((cpPolyShape *)shape)->numVerts;
|
||||
}
|
||||
|
||||
cpVect
|
||||
cpPolyShapeGetVert(cpShape *shape, int idx)
|
||||
cpPolyShapeGetVert(const cpShape *shape, int idx)
|
||||
{
|
||||
cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape.");
|
||||
cpAssertHard(0 <= idx && idx < cpPolyShapeGetNumVerts(shape), "Index out of range.");
|
||||
|
@ -179,6 +200,13 @@ cpPolyShapeGetVert(cpShape *shape, int idx)
|
|||
return ((cpPolyShape *)shape)->verts[idx];
|
||||
}
|
||||
|
||||
cpFloat
|
||||
cpPolyShapeGetRadius(const cpShape *shape)
|
||||
{
|
||||
cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape.");
|
||||
return ((cpPolyShape *)shape)->r;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
setUpVerts(cpPolyShape *poly, int numVerts, const cpVect *verts, cpVect offset)
|
||||
|
@ -202,21 +230,39 @@ setUpVerts(cpPolyShape *poly, int numVerts, const cpVect *verts, cpVect offset)
|
|||
poly->planes[i].d = cpvdot(n, a);
|
||||
}
|
||||
|
||||
// TODO: Why did I add this? It duplicates work from above.
|
||||
for(int i=0; i<numVerts; i++){
|
||||
poly->planes[i] = cpSplittingPlaneNew(poly->verts[(i - 1 + numVerts)%numVerts], poly->verts[i]);
|
||||
}
|
||||
}
|
||||
|
||||
cpPolyShape *
|
||||
cpPolyShapeInit(cpPolyShape *poly, cpBody *body, int numVerts, const cpVect *verts, cpVect offset)
|
||||
{
|
||||
return cpPolyShapeInit2(poly, body, numVerts, verts, offset, 0.0f);
|
||||
}
|
||||
|
||||
cpPolyShape *
|
||||
cpPolyShapeInit2(cpPolyShape *poly, cpBody *body, int numVerts, const cpVect *verts, cpVect offset, cpFloat radius)
|
||||
{
|
||||
setUpVerts(poly, numVerts, verts, offset);
|
||||
cpShapeInit((cpShape *)poly, &polyClass, body);
|
||||
poly->r = radius;
|
||||
|
||||
return poly;
|
||||
}
|
||||
|
||||
|
||||
cpShape *
|
||||
cpPolyShapeNew(cpBody *body, int numVerts, cpVect *verts, cpVect offset)
|
||||
cpPolyShapeNew(cpBody *body, int numVerts, const cpVect *verts, cpVect offset)
|
||||
{
|
||||
return (cpShape *)cpPolyShapeInit(cpPolyShapeAlloc(), body, numVerts, verts, offset);
|
||||
return cpPolyShapeNew2(body, numVerts, verts, offset, 0.0f);
|
||||
}
|
||||
|
||||
cpShape *
|
||||
cpPolyShapeNew2(cpBody *body, int numVerts, const cpVect *verts, cpVect offset, cpFloat radius)
|
||||
{
|
||||
return (cpShape *)cpPolyShapeInit2(cpPolyShapeAlloc(), body, numVerts, verts, offset, radius);
|
||||
}
|
||||
|
||||
cpPolyShape *
|
||||
|
@ -230,6 +276,12 @@ cpBoxShapeInit(cpPolyShape *poly, cpBody *body, cpFloat width, cpFloat height)
|
|||
|
||||
cpPolyShape *
|
||||
cpBoxShapeInit2(cpPolyShape *poly, cpBody *body, cpBB box)
|
||||
{
|
||||
return cpBoxShapeInit3(poly, body, box, 0.0f);
|
||||
}
|
||||
|
||||
cpPolyShape *
|
||||
cpBoxShapeInit3(cpPolyShape *poly, cpBody *body, cpBB box, cpFloat radius)
|
||||
{
|
||||
cpVect verts[] = {
|
||||
cpv(box.l, box.b),
|
||||
|
@ -238,7 +290,7 @@ cpBoxShapeInit2(cpPolyShape *poly, cpBody *body, cpBB box)
|
|||
cpv(box.r, box.b),
|
||||
};
|
||||
|
||||
return cpPolyShapeInit(poly, body, 4, verts, cpvzero);
|
||||
return cpPolyShapeInit2(poly, body, 4, verts, cpvzero, radius);
|
||||
}
|
||||
|
||||
cpShape *
|
||||
|
@ -253,6 +305,12 @@ cpBoxShapeNew2(cpBody *body, cpBB box)
|
|||
return (cpShape *)cpBoxShapeInit2(cpPolyShapeAlloc(), body, box);
|
||||
}
|
||||
|
||||
cpShape *
|
||||
cpBoxShapeNew3(cpBody *body, cpBB box, cpFloat radius)
|
||||
{
|
||||
return (cpShape *)cpBoxShapeInit3(cpPolyShapeAlloc(), body, box, radius);
|
||||
}
|
||||
|
||||
// Unsafe API (chipmunk_unsafe.h)
|
||||
|
||||
void
|
||||
|
@ -262,3 +320,10 @@ cpPolyShapeSetVerts(cpShape *shape, int numVerts, cpVect *verts, cpVect offset)
|
|||
cpPolyShapeDestroy((cpPolyShape *)shape);
|
||||
setUpVerts((cpPolyShape *)shape, numVerts, verts, offset);
|
||||
}
|
||||
|
||||
void
|
||||
cpPolyShapeSetRadius(cpShape *shape, cpFloat radius)
|
||||
{
|
||||
cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape.");
|
||||
((cpPolyShape *)shape)->r = radius;
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ cpShapeUpdate(cpShape *shape, cpVect pos, cpVect rot)
|
|||
|
||||
cpBool
|
||||
cpShapePointQuery(cpShape *shape, cpVect p){
|
||||
cpNearestPointQueryInfo info = {NULL, cpvzero, INFINITY};
|
||||
cpNearestPointQueryInfo info = {NULL, cpvzero, INFINITY, cpvzero};
|
||||
cpShapeNearestPointQuery(shape, p, &info);
|
||||
|
||||
return (info.d < 0.0f);
|
||||
|
@ -112,7 +112,7 @@ cpShapePointQuery(cpShape *shape, cpVect p){
|
|||
cpFloat
|
||||
cpShapeNearestPointQuery(cpShape *shape, cpVect p, cpNearestPointQueryInfo *info)
|
||||
{
|
||||
cpNearestPointQueryInfo blank = {NULL, cpvzero, INFINITY};
|
||||
cpNearestPointQueryInfo blank = {NULL, cpvzero, INFINITY, cpvzero};
|
||||
if(info){
|
||||
(*info) = blank;
|
||||
} else {
|
||||
|
@ -126,7 +126,7 @@ cpShapeNearestPointQuery(cpShape *shape, cpVect p, cpNearestPointQueryInfo *info
|
|||
|
||||
cpBool
|
||||
cpShapeSegmentQuery(cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info){
|
||||
cpSegmentQueryInfo blank = {NULL, 0.0f, cpvzero};
|
||||
cpSegmentQueryInfo blank = {NULL, 1.0f, cpvzero};
|
||||
if(info){
|
||||
(*info) = blank;
|
||||
} else {
|
||||
|
@ -169,34 +169,15 @@ cpCicleShapeNearestPointQuery(cpCircleShape *circle, cpVect p, cpNearestPointQue
|
|||
info->shape = (cpShape *)circle;
|
||||
info->p = cpvadd(circle->tc, cpvmult(delta, r/d)); // TODO div/0
|
||||
info->d = d - r;
|
||||
}
|
||||
|
||||
static void
|
||||
circleSegmentQuery(cpShape *shape, cpVect center, cpFloat r, cpVect a, cpVect b, cpSegmentQueryInfo *info)
|
||||
{
|
||||
cpVect da = cpvsub(a, center);
|
||||
cpVect db = cpvsub(b, center);
|
||||
|
||||
cpFloat qa = cpvdot(da, da) - 2.0f*cpvdot(da, db) + cpvdot(db, db);
|
||||
cpFloat qb = -2.0f*cpvdot(da, da) + 2.0f*cpvdot(da, db);
|
||||
cpFloat qc = cpvdot(da, da) - r*r;
|
||||
|
||||
cpFloat det = qb*qb - 4.0f*qa*qc;
|
||||
|
||||
if(det >= 0.0f){
|
||||
cpFloat t = (-qb - cpfsqrt(det))/(2.0f*qa);
|
||||
if(0.0f<= t && t <= 1.0f){
|
||||
info->shape = shape;
|
||||
info->t = t;
|
||||
info->n = cpvnormalize(cpvlerp(da, db, t));
|
||||
}
|
||||
}
|
||||
// Use up for the gradient if the distance is very small.
|
||||
info->g = (d > MAGIC_EPSILON ? cpvmult(delta, 1.0f/d) : cpv(0.0f, 1.0f));
|
||||
}
|
||||
|
||||
static void
|
||||
cpCircleShapeSegmentQuery(cpCircleShape *circle, cpVect a, cpVect b, cpSegmentQueryInfo *info)
|
||||
{
|
||||
circleSegmentQuery((cpShape *)circle, circle->tc, circle->r, a, b, info);
|
||||
CircleSegmentQuery((cpShape *)circle, circle->tc, circle->r, a, b, info);
|
||||
}
|
||||
|
||||
static const cpShapeClass cpCircleShapeClass = {
|
||||
|
@ -270,10 +251,14 @@ cpSegmentShapeNearestPointQuery(cpSegmentShape *seg, cpVect p, cpNearestPointQue
|
|||
cpVect delta = cpvsub(p, closest);
|
||||
cpFloat d = cpvlength(delta);
|
||||
cpFloat r = seg->r;
|
||||
cpVect g = cpvmult(delta, 1.0f/d);
|
||||
|
||||
info->shape = (cpShape *)seg;
|
||||
info->p = (d ? cpvadd(closest, cpvmult(delta, r/d)) : closest);
|
||||
info->p = (d ? cpvadd(closest, cpvmult(g, r)) : closest);
|
||||
info->d = d - r;
|
||||
|
||||
// Use the segment's normal if the distance is very small.
|
||||
info->g = (d > MAGIC_EPSILON ? g : seg->n);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -304,8 +289,8 @@ cpSegmentShapeSegmentQuery(cpSegmentShape *seg, cpVect a, cpVect b, cpSegmentQue
|
|||
} else if(r != 0.0f){
|
||||
cpSegmentQueryInfo info1 = {NULL, 1.0f, cpvzero};
|
||||
cpSegmentQueryInfo info2 = {NULL, 1.0f, cpvzero};
|
||||
circleSegmentQuery((cpShape *)seg, seg->ta, seg->r, a, b, &info1);
|
||||
circleSegmentQuery((cpShape *)seg, seg->tb, seg->r, a, b, &info2);
|
||||
CircleSegmentQuery((cpShape *)seg, seg->ta, seg->r, a, b, &info1);
|
||||
CircleSegmentQuery((cpShape *)seg, seg->tb, seg->r, a, b, &info2);
|
||||
|
||||
if(info1.t < info2.t){
|
||||
(*info) = info1;
|
||||
|
|
|
@ -362,7 +362,7 @@ query_helper(cpSpaceHash *hash, cpSpaceHashBin **bin_ptr, void *obj, cpSpatialIn
|
|||
if(hand->stamp == hash->stamp || obj == other){
|
||||
continue;
|
||||
} else if(other){
|
||||
func(obj, other, data);
|
||||
func(obj, other, 0, data);
|
||||
hand->stamp = hash->stamp;
|
||||
} else {
|
||||
// The object for this handle has been removed
|
||||
|
|
|
@ -31,8 +31,8 @@ struct PointQueryContext {
|
|||
void *data;
|
||||
};
|
||||
|
||||
static void
|
||||
PointQuery(struct PointQueryContext *context, cpShape *shape, void *data)
|
||||
static cpCollisionID
|
||||
PointQuery(struct PointQueryContext *context, cpShape *shape, cpCollisionID id, void *data)
|
||||
{
|
||||
if(
|
||||
!(shape->group && context->group == shape->group) && (context->layers&shape->layers) &&
|
||||
|
@ -40,6 +40,8 @@ PointQuery(struct PointQueryContext *context, cpShape *shape, void *data)
|
|||
){
|
||||
context->func(shape, context->data);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -79,8 +81,8 @@ struct NearestPointQueryContext {
|
|||
cpSpaceNearestPointQueryFunc func;
|
||||
};
|
||||
|
||||
static void
|
||||
NearestPointQuery(struct NearestPointQueryContext *context, cpShape *shape, void *data)
|
||||
static cpCollisionID
|
||||
NearestPointQuery(struct NearestPointQueryContext *context, cpShape *shape, cpCollisionID id, void *data)
|
||||
{
|
||||
if(
|
||||
!(shape->group && context->group == shape->group) && (context->layers&shape->layers)
|
||||
|
@ -90,6 +92,8 @@ NearestPointQuery(struct NearestPointQueryContext *context, cpShape *shape, void
|
|||
|
||||
if(info.shape && info.d < context->maxDistance) context->func(shape, info.d, info.p, data);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -104,8 +108,8 @@ cpSpaceNearestPointQuery(cpSpace *space, cpVect point, cpFloat maxDistance, cpLa
|
|||
} cpSpaceUnlock(space, cpTrue);
|
||||
}
|
||||
|
||||
static void
|
||||
NearestPointQueryNearest(struct NearestPointQueryContext *context, cpShape *shape, cpNearestPointQueryInfo *out)
|
||||
static cpCollisionID
|
||||
NearestPointQueryNearest(struct NearestPointQueryContext *context, cpShape *shape, cpCollisionID id, cpNearestPointQueryInfo *out)
|
||||
{
|
||||
if(
|
||||
!(shape->group && context->group == shape->group) && (context->layers&shape->layers) && !shape->sensor
|
||||
|
@ -115,12 +119,14 @@ NearestPointQueryNearest(struct NearestPointQueryContext *context, cpShape *shap
|
|||
|
||||
if(info.d < out->d) (*out) = info;
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
cpShape *
|
||||
cpSpaceNearestPointQueryNearest(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpNearestPointQueryInfo *out)
|
||||
{
|
||||
cpNearestPointQueryInfo info = {NULL, cpvzero, maxDistance};
|
||||
cpNearestPointQueryInfo info = {NULL, cpvzero, maxDistance, cpvzero};
|
||||
if(out){
|
||||
(*out) = info;
|
||||
} else {
|
||||
|
@ -228,8 +234,8 @@ struct BBQueryContext {
|
|||
cpSpaceBBQueryFunc func;
|
||||
};
|
||||
|
||||
static void
|
||||
BBQuery(struct BBQueryContext *context, cpShape *shape, void *data)
|
||||
static cpCollisionID
|
||||
BBQuery(struct BBQueryContext *context, cpShape *shape, cpCollisionID id, void *data)
|
||||
{
|
||||
if(
|
||||
!(shape->group && context->group == shape->group) && (context->layers&shape->layers) &&
|
||||
|
@ -237,6 +243,8 @@ BBQuery(struct BBQueryContext *context, cpShape *shape, void *data)
|
|||
){
|
||||
context->func(shape, data);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -259,24 +267,24 @@ struct ShapeQueryContext {
|
|||
};
|
||||
|
||||
// Callback from the spatial hash.
|
||||
static void
|
||||
ShapeQuery(cpShape *a, cpShape *b, struct ShapeQueryContext *context)
|
||||
static cpCollisionID
|
||||
ShapeQuery(cpShape *a, cpShape *b, cpCollisionID id, struct ShapeQueryContext *context)
|
||||
{
|
||||
// Reject any of the simple cases
|
||||
if(
|
||||
(a->group && a->group == b->group) ||
|
||||
!(a->layers & b->layers) ||
|
||||
a == b
|
||||
) return;
|
||||
) return id;
|
||||
|
||||
cpContact contacts[CP_MAX_CONTACTS_PER_ARBITER];
|
||||
int numContacts = 0;
|
||||
|
||||
// Shape 'a' should have the lower shape type. (required by cpCollideShapes() )
|
||||
if(a->klass->type <= b->klass->type){
|
||||
numContacts = cpCollideShapes(a, b, contacts);
|
||||
numContacts = cpCollideShapes(a, b, &id, contacts);
|
||||
} else {
|
||||
numContacts = cpCollideShapes(b, a, contacts);
|
||||
numContacts = cpCollideShapes(b, a, &id, contacts);
|
||||
for(int i=0; i<numContacts; i++) contacts[i].n = cpvneg(contacts[i].n);
|
||||
}
|
||||
|
||||
|
@ -296,6 +304,8 @@ ShapeQuery(cpShape *a, cpShape *b, struct ShapeQueryContext *context)
|
|||
context->func(b, &set, context->data);
|
||||
}
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
cpBool
|
||||
|
|
|
@ -219,19 +219,20 @@ queryReject(cpShape *a, cpShape *b)
|
|||
}
|
||||
|
||||
// Callback from the spatial hash.
|
||||
void
|
||||
cpSpaceCollideShapes(cpShape *a, cpShape *b, cpSpace *space)
|
||||
cpCollisionID
|
||||
cpSpaceCollideShapes(cpShape *a, cpShape *b, cpCollisionID id, cpSpace *space)
|
||||
{
|
||||
// Reject any of the simple cases
|
||||
if(queryReject(a,b)) return;
|
||||
if(queryReject(a,b)) return id;
|
||||
|
||||
cpCollisionHandler *handler = cpSpaceLookupHandler(space, a->collision_type, b->collision_type);
|
||||
|
||||
cpBool sensor = a->sensor || b->sensor;
|
||||
if(sensor && handler == &cpDefaultCollisionHandler) return;
|
||||
if(sensor && handler == &cpDefaultCollisionHandler) return id;
|
||||
|
||||
// Shape 'a' should have the lower shape type. (required by cpCollideShapes() )
|
||||
if(a->klass->type > b->klass->type){
|
||||
// TODO remove me: a < b comparison is for debugging collisions
|
||||
if(a->klass->type > b->klass->type || (a->klass->type == b->klass->type && a < b)){
|
||||
cpShape *temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
|
@ -239,8 +240,8 @@ cpSpaceCollideShapes(cpShape *a, cpShape *b, cpSpace *space)
|
|||
|
||||
// Narrow-phase collision detection.
|
||||
cpContact *contacts = cpContactBufferGetArray(space);
|
||||
int numContacts = cpCollideShapes(a, b, contacts);
|
||||
if(!numContacts) return; // Shapes are not colliding.
|
||||
int numContacts = cpCollideShapes(a, b, &id, contacts);
|
||||
if(!numContacts) return id; // Shapes are not colliding.
|
||||
cpSpacePushContacts(space, numContacts);
|
||||
|
||||
// Get an arbiter from space->arbiterSet for the two shapes.
|
||||
|
@ -277,6 +278,7 @@ cpSpaceCollideShapes(cpShape *a, cpShape *b, cpSpace *space)
|
|||
|
||||
// Time stamp the arbiter so we know it was used recently.
|
||||
arb->stamp = space->stamp;
|
||||
return id;
|
||||
}
|
||||
|
||||
// Hashset filter func to throw away old arbiters.
|
||||
|
|
|
@ -183,7 +183,7 @@ cpSweep1DQuery(cpSweep1D *sweep, void *obj, cpBB bb, cpSpatialIndexQueryFunc fun
|
|||
TableCell *table = sweep->table;
|
||||
for(int i=0, count=sweep->num; i<count; i++){
|
||||
TableCell cell = table[i];
|
||||
if(BoundsOverlap(bounds, cell.bounds) && obj != cell.obj) func(obj, cell.obj, data);
|
||||
if(BoundsOverlap(bounds, cell.bounds) && obj != cell.obj) func(obj, cell.obj, 0, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ cpSweep1DReindexQuery(cpSweep1D *sweep, cpSpatialIndexQueryFunc func, void *data
|
|||
cpFloat max = cell.bounds.max;
|
||||
|
||||
for(int j=i+1; table[j].bounds.min < max && j<count; j++){
|
||||
func(cell.obj, table[j].obj, data);
|
||||
func(cell.obj, table[j].obj, 0, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
fa70974de744fb12ec4f753989e6e0a7eb9fc73a
|
||||
d53bc7d6e68a49984c5971344f59bba8414d142b
|
|
@ -32,7 +32,7 @@ ChipmunkTestLayer::ChipmunkTestLayer()
|
|||
|
||||
// title
|
||||
auto label = LabelTTF::create("Multi touch the screen", "Marker Felt", 36);
|
||||
label->setPosition(Point( VisibleRect::center().x, VisibleRect::top().y - 30));
|
||||
label->setPosition(cocos2d::Point( VisibleRect::center().x, VisibleRect::top().y - 30));
|
||||
this->addChild(label, -1);
|
||||
|
||||
// reset button
|
||||
|
@ -52,7 +52,7 @@ ChipmunkTestLayer::ChipmunkTestLayer()
|
|||
#endif
|
||||
addChild(parent, 0, kTagParentNode);
|
||||
|
||||
addNewSpriteAtPosition(Point(200,200));
|
||||
addNewSpriteAtPosition(cocos2d::Point(200,200));
|
||||
|
||||
// menu for debug layer
|
||||
MenuItemFont::setFontSize(18);
|
||||
|
@ -60,7 +60,7 @@ ChipmunkTestLayer::ChipmunkTestLayer()
|
|||
|
||||
auto menu = Menu::create(item, NULL);
|
||||
this->addChild(menu);
|
||||
menu->setPosition(Point(VisibleRect::right().x-100, VisibleRect::top().y-60));
|
||||
menu->setPosition(cocos2d::Point(VisibleRect::right().x-100, VisibleRect::top().y-60));
|
||||
|
||||
scheduleUpdate();
|
||||
#else
|
||||
|
@ -160,7 +160,7 @@ void ChipmunkTestLayer::createResetButton()
|
|||
|
||||
auto menu = Menu::create(reset, NULL);
|
||||
|
||||
menu->setPosition(Point(VisibleRect::center().x, VisibleRect::bottom().y + 30));
|
||||
menu->setPosition(cocos2d::Point(VisibleRect::center().x, VisibleRect::bottom().y + 30));
|
||||
this->addChild(menu, -1);
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ void ChipmunkTestLayer::reset(Ref* sender)
|
|||
s->release();
|
||||
}
|
||||
|
||||
void ChipmunkTestLayer::addNewSpriteAtPosition(Point pos)
|
||||
void ChipmunkTestLayer::addNewSpriteAtPosition(cocos2d::Point pos)
|
||||
{
|
||||
#if CC_ENABLE_CHIPMUNK_INTEGRATION
|
||||
int posx, posy;
|
||||
|
@ -205,7 +205,7 @@ void ChipmunkTestLayer::addNewSpriteAtPosition(Point pos)
|
|||
shape->e = 0.5f; shape->u = 0.5f;
|
||||
cpSpaceAddShape(_space, shape);
|
||||
|
||||
auto sprite = PhysicsSprite::createWithTexture(_spriteTexture, Rect(posx, posy, 85, 121));
|
||||
auto sprite = PhysicsSprite::createWithTexture(_spriteTexture, cocos2d::Rect(posx, posy, 85, 121));
|
||||
parent->addChild(sprite);
|
||||
|
||||
sprite->setCPBody(body);
|
||||
|
@ -242,7 +242,7 @@ void ChipmunkTestLayer::onAcceleration(Acceleration* acc, Event* event)
|
|||
prevX = accelX;
|
||||
prevY = accelY;
|
||||
|
||||
auto v = Point( accelX, accelY);
|
||||
auto v = cocos2d::Point( accelX, accelY);
|
||||
v = v * 200;
|
||||
_space->gravity = cpv(v.x, v.y);
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
void createResetButton();
|
||||
void reset(Ref* sender);
|
||||
|
||||
void addNewSpriteAtPosition(Point p);
|
||||
void addNewSpriteAtPosition(cocos2d::Point p);
|
||||
void update(float dt);
|
||||
void toggleDebugCallback(Ref* sender);
|
||||
void onTouchesEnded(const std::vector<Touch*>& touches, Event* event);
|
||||
|
|
|
@ -1040,7 +1040,7 @@ void TestColliderDetector::update(float delta)
|
|||
|
||||
float minx = 0, miny = 0, maxx = 0, maxy = 0;
|
||||
size_t length = vertexList.size();
|
||||
for (int i = 0; i<length; i++)
|
||||
for (size_t i = 0; i<length; i++)
|
||||
{
|
||||
Point vertex = vertexList.at(i);
|
||||
if (i == 0)
|
||||
|
|
|
@ -48,7 +48,7 @@ void CustomImageView::initRenderer()
|
|||
ImageView::initRenderer();
|
||||
|
||||
_label = LabelTTF::create();
|
||||
CCNodeRGBA::addChild(_label, getZOrder() + 1, -1);
|
||||
CCNodeRGBA::addChild(_label, getLocalZOrder() + 1, -1);
|
||||
}
|
||||
|
||||
void CustomImageView::setText(const std::string &text)
|
||||
|
|
|
@ -72,7 +72,7 @@ void CustomParticleWidget::setParticlePlist(const char *plist)
|
|||
_emitter->removeFromParent();
|
||||
_emitter = ParticleSystemQuad::create(plist);
|
||||
}
|
||||
Node::addChild(_emitter , getZOrder() + 1, -1);
|
||||
Node::addChild(_emitter , getLocalZOrder() + 1, -1);
|
||||
|
||||
_emitterPlist = plist;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ bool UILayoutTest_Editor::init()
|
|||
left_button->getSize().height));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -47,7 +47,7 @@ bool UILayoutTest_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
@ -94,7 +94,7 @@ bool UILayoutTest_Color_Editor::init()
|
|||
left_button->getSize().height));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -102,7 +102,7 @@ bool UILayoutTest_Color_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
@ -149,7 +149,7 @@ bool UILayoutTest_Gradient_Editor::init()
|
|||
left_button->getSize().height));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -157,7 +157,7 @@ bool UILayoutTest_Gradient_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
@ -204,7 +204,7 @@ bool UILayoutTest_BackGroundImage_Editor::init()
|
|||
left_button->getSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -212,7 +212,7 @@ bool UILayoutTest_BackGroundImage_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
@ -259,7 +259,7 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
|
|||
left_button->getSize().height));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -267,7 +267,7 @@ bool UILayoutTest_BackGroundImage_Scale9_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
@ -314,7 +314,7 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
|
|||
left_button->getSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -322,7 +322,7 @@ bool UILayoutTest_Layout_Linear_Vertical_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
@ -369,7 +369,7 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
|
|||
left_button->getSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -377,7 +377,7 @@ bool UILayoutTest_Layout_Linear_Horizontal_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
@ -425,7 +425,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
|
|||
left_button->getSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -433,7 +433,7 @@ bool UILayoutTest_Layout_Relative_Align_Parent_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
@ -480,7 +480,7 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init()
|
|||
left_button->getSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -488,7 +488,7 @@ bool UILayoutTest_Layout_Relative_Location_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ bool UIListViewTest_Vertical_Editor::init()
|
|||
left_button->getSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -50,7 +50,7 @@ bool UIListViewTest_Vertical_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
@ -98,7 +98,7 @@ bool UIListViewTest_Horizontal_Editor::init()
|
|||
left_button->getSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -106,7 +106,7 @@ bool UIListViewTest_Horizontal_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
return true;
|
||||
|
|
|
@ -40,7 +40,7 @@ bool UIPageViewTest_Editor::init()
|
|||
left_button->getSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -48,7 +48,7 @@ bool UIPageViewTest_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ bool UIRichTextTest::init()
|
|||
button->setTitleText("switch");
|
||||
button->setPosition(Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + button->getSize().height * 2.5));
|
||||
button->addTouchEventListener(this, toucheventselector(UIRichTextTest::touchEvent));
|
||||
button->setZOrder(10);
|
||||
button->setLocalZOrder(10);
|
||||
_widget->addChild(button);
|
||||
|
||||
|
||||
|
@ -69,7 +69,7 @@ bool UIRichTextTest::init()
|
|||
_richText->pushBackElement(re6);
|
||||
|
||||
_richText->setPosition(Point(widgetSize.width / 2, widgetSize.height / 2));
|
||||
_richText->setZOrder(10);
|
||||
_richText->setLocalZOrder(10);
|
||||
|
||||
|
||||
_widget->addChild(_richText);
|
||||
|
|
|
@ -39,7 +39,7 @@ bool UIScrollViewTest_Vertical_Editor::init()
|
|||
left_button->getSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -47,7 +47,7 @@ bool UIScrollViewTest_Vertical_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
@ -94,7 +94,7 @@ bool UIScrollViewTest_Horizontal_Editor::init()
|
|||
left_button->getSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -102,7 +102,7 @@ bool UIScrollViewTest_Horizontal_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
@ -149,7 +149,7 @@ bool UIScrollViewTest_Both_Editor::init()
|
|||
left_button->getSize().height * 0.625));
|
||||
left_button->setTouchEnabled(true);
|
||||
left_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::previousCallback));
|
||||
left_button->setZOrder(_layout->getZOrder() + 1);
|
||||
left_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(left_button);
|
||||
|
||||
Button* right_button = Button::create();
|
||||
|
@ -157,7 +157,7 @@ bool UIScrollViewTest_Both_Editor::init()
|
|||
right_button->setPosition(Point(_layout->getSize().width / 2 + right_button->getSize().width,
|
||||
right_button->getSize().height * 0.625));
|
||||
right_button->setTouchEnabled(true);
|
||||
right_button->setZOrder(_layout->getZOrder() + 1);
|
||||
right_button->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
right_button->addTouchEventListener(this, toucheventselector(UIScene_Editor::nextCallback));
|
||||
_layout->addChild(right_button);
|
||||
|
||||
|
|
|
@ -336,7 +336,7 @@ void UITextFieldTest_LineWrap::textFieldEvent(Ref *pSender, TextFiledEventType t
|
|||
{
|
||||
TextField* textField = dynamic_cast<TextField*>(pSender);
|
||||
Size widgetSize = _widget->getSize();
|
||||
textField->runAction(CCMoveTo::create(0.225,
|
||||
textField->runAction(CCMoveTo::create(0.225f,
|
||||
Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f + textField->getContentSize().height / 2)));
|
||||
textField->setTextHorizontalAlignment(TextHAlignment::LEFT);
|
||||
textField->setTextVerticalAlignment(TextVAlignment::TOP);
|
||||
|
@ -349,7 +349,7 @@ void UITextFieldTest_LineWrap::textFieldEvent(Ref *pSender, TextFiledEventType t
|
|||
{
|
||||
TextField* textField = dynamic_cast<TextField*>(pSender);
|
||||
Size widgetSize = _widget->getSize();
|
||||
textField->runAction(CCMoveTo::create(0.175, Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)));
|
||||
textField->runAction(CCMoveTo::create(0.175f, Point(widgetSize.width / 2.0f, widgetSize.height / 2.0f)));
|
||||
textField->setTextHorizontalAlignment(TextHAlignment::CENTER);
|
||||
textField->setTextVerticalAlignment(TextVAlignment::CENTER);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ bool UIWidgetAddNodeTest_Editor::init()
|
|||
// Create the ui widget
|
||||
Widget* widget = Widget::create();
|
||||
widget->setPosition(Point(rootSize.width / 2.0f, rootSize.height / 2.0f));
|
||||
widget->setZOrder(_layout->getZOrder() + 1);
|
||||
widget->setLocalZOrder(_layout->getLocalZOrder() + 1);
|
||||
_layout->addChild(widget);
|
||||
|
||||
Sprite* sprite = Sprite::create("cocosui/ccicon.png");
|
||||
|
|
8
tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp
Executable file → Normal file
8
tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp
Executable file → Normal file
|
@ -199,7 +199,7 @@ void TMoveBy::serialize(const rapidjson::Value &val)
|
|||
}
|
||||
else if (key == "IsReverse")
|
||||
{
|
||||
_reverse = (bool)(DICTOOL->getIntValue_json(subDict, "value"));
|
||||
_reverse = DICTOOL->getIntValue_json(subDict, "value") ? true : false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ void TRotateBy::serialize(const rapidjson::Value &val)
|
|||
}
|
||||
else if (key == "IsReverse")
|
||||
{
|
||||
_reverse = (int)(DICTOOL->getIntValue_json(subDict, "value"));
|
||||
_reverse = (DICTOOL->getIntValue_json(subDict, "value")) ? true : false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ void TScaleBy::serialize(const rapidjson::Value &val)
|
|||
}
|
||||
else if (key == "IsReverse")
|
||||
{
|
||||
_reverse = (bool)(DICTOOL->getIntValue_json(subDict, "value"));
|
||||
_reverse = (DICTOOL->getIntValue_json(subDict, "value")) ? true : false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -629,7 +629,7 @@ void TSkewBy::serialize(const rapidjson::Value &val)
|
|||
}
|
||||
else if (key == "IsReverse")
|
||||
{
|
||||
_reverse = (bool)(DICTOOL->getIntValue_json(subDict, "value"));
|
||||
_reverse = DICTOOL->getIntValue_json(subDict, "value") ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
2
tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp
Executable file → Normal file
2
tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/cons.cpp
Executable file → Normal file
|
@ -255,7 +255,7 @@ void NodeVisible::serialize(const rapidjson::Value &val)
|
|||
}
|
||||
else if (key == "Visible")
|
||||
{
|
||||
_visible = DICTOOL->getIntValue_json(subDict, "value");
|
||||
_visible = DICTOOL->getIntValue_json(subDict, "value") ? true : false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1547,7 +1547,11 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke()
|
|||
strokeShaodwTextDef._fontFillColor = tintColorBlue;
|
||||
|
||||
// shadow + stroke label
|
||||
auto fontStrokeAndShadow = LabelTTF::createWithFontDefinition("Stroke & Shadow Blue Text", strokeShaodwTextDef);
|
||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32
|
||||
auto fontStrokeAndShadow = LabelTTF::createWithFontDefinition("Stroke && Shadow Blue Text", strokeShaodwTextDef);
|
||||
#else
|
||||
auto fontStrokeAndShadow = LabelTTF::createWithFontDefinition("Stroke &Shadow Blue Text", strokeShaodwTextDef);
|
||||
#endif
|
||||
|
||||
// add label to the scene
|
||||
this->addChild(fontStrokeAndShadow);
|
||||
|
|
|
@ -845,7 +845,7 @@ void PhysicsDemoJoints::onEnter()
|
|||
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition()));
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition()));
|
||||
PhysicsJointRotaryLimit* joint = PhysicsJointRotaryLimit::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 0.0f, M_PI_2);
|
||||
PhysicsJointRotaryLimit* joint = PhysicsJointRotaryLimit::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 0.0f,(float) M_PI_2);
|
||||
_scene->getPhysicsWorld()->addJoint(joint);
|
||||
|
||||
this->addChild(sp1);
|
||||
|
@ -861,7 +861,7 @@ void PhysicsDemoJoints::onEnter()
|
|||
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition()));
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition()));
|
||||
PhysicsJointRatchet* joint = PhysicsJointRatchet::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 0.0f, M_PI_2);
|
||||
PhysicsJointRatchet* joint = PhysicsJointRatchet::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), 0.0f, (float)M_PI_2);
|
||||
_scene->getPhysicsWorld()->addJoint(joint);
|
||||
|
||||
this->addChild(sp1);
|
||||
|
@ -893,7 +893,7 @@ void PhysicsDemoJoints::onEnter()
|
|||
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp1->getPhysicsBody(), box, sp1->getPosition()));
|
||||
_scene->getPhysicsWorld()->addJoint(PhysicsJointPin::construct(sp2->getPhysicsBody(), box, sp2->getPosition()));
|
||||
PhysicsJointMotor* joint = PhysicsJointMotor::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), M_PI_2);
|
||||
PhysicsJointMotor* joint = PhysicsJointMotor::construct(sp1->getPhysicsBody(), sp2->getPhysicsBody(), (float)M_PI_2);
|
||||
_scene->getPhysicsWorld()->addJoint(joint);
|
||||
|
||||
this->addChild(sp1);
|
||||
|
@ -1445,7 +1445,7 @@ void PhysicsContactTest::resetTest()
|
|||
label->setPosition(Point(s.width/2, s.height-170));
|
||||
|
||||
auto wall = Node::create();
|
||||
wall->setPhysicsBody(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1, 1, 0.0)));
|
||||
wall->setPhysicsBody(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size, PhysicsMaterial(0.1f, 1, 0.0f)));
|
||||
wall->setPosition(VisibleRect::center());
|
||||
root->addChild(wall);
|
||||
|
||||
|
@ -1463,7 +1463,7 @@ void PhysicsContactTest::resetTest()
|
|||
position.y = position.y * CCRANDOM_0_1();
|
||||
position = VisibleRect::leftBottom() + position + Point(size.width/2, size.height/2);
|
||||
Vect velocity((CCRANDOM_0_1() - 0.5)*200, (CCRANDOM_0_1() - 0.5)*200);
|
||||
auto box = makeBox(position, size, 1, PhysicsMaterial(0.1, 1, 0.0));
|
||||
auto box = makeBox(position, size, 1, PhysicsMaterial(0.1f, 1, 0.0f));
|
||||
box->getPhysicsBody()->setVelocity(velocity);
|
||||
box->getPhysicsBody()->setCategoryBitmask(0x01); // 0001
|
||||
box->getPhysicsBody()->setContactTestBitmask(0x04); // 0100
|
||||
|
@ -1481,7 +1481,7 @@ void PhysicsContactTest::resetTest()
|
|||
position.y = position.y * CCRANDOM_0_1();
|
||||
position = VisibleRect::leftBottom() + position + Point(size.width/2, size.height/2);
|
||||
Vect velocity((CCRANDOM_0_1() - 0.5)*200, (CCRANDOM_0_1() - 0.5)*200);
|
||||
auto box = makeBox(position, size, 2, PhysicsMaterial(0.1, 1, 0.0));
|
||||
auto box = makeBox(position, size, 2, PhysicsMaterial(0.1f, 1, 0.0f));
|
||||
box->getPhysicsBody()->setVelocity(velocity);
|
||||
box->getPhysicsBody()->setCategoryBitmask(0x02); // 0010
|
||||
box->getPhysicsBody()->setContactTestBitmask(0x08); // 1000
|
||||
|
@ -1499,7 +1499,7 @@ void PhysicsContactTest::resetTest()
|
|||
position.y = position.y * CCRANDOM_0_1();
|
||||
position = VisibleRect::leftBottom() + position + Point(size.width/2, size.height/2);
|
||||
Vect velocity((CCRANDOM_0_1() - 0.5)*300, (CCRANDOM_0_1() - 0.5)*300);
|
||||
auto triangle = makeTriangle(position, size, 1, PhysicsMaterial(0.1, 1, 0.0));
|
||||
auto triangle = makeTriangle(position, size, 1, PhysicsMaterial(0.1f, 1, 0.0f));
|
||||
triangle->getPhysicsBody()->setVelocity(velocity);
|
||||
triangle->getPhysicsBody()->setCategoryBitmask(0x04); // 0100
|
||||
triangle->getPhysicsBody()->setContactTestBitmask(0x01); // 0001
|
||||
|
@ -1517,7 +1517,7 @@ void PhysicsContactTest::resetTest()
|
|||
position.y = position.y * CCRANDOM_0_1();
|
||||
position = VisibleRect::leftBottom() + position + Point(size.width/2, size.height/2);
|
||||
Vect velocity((CCRANDOM_0_1() - 0.5)*300, (CCRANDOM_0_1() - 0.5)*300);
|
||||
auto triangle = makeTriangle(position, size, 2, PhysicsMaterial(0.1, 1, 0.0));
|
||||
auto triangle = makeTriangle(position, size, 2, PhysicsMaterial(0.1f, 1, 0.0f));
|
||||
triangle->getPhysicsBody()->setVelocity(velocity);
|
||||
triangle->getPhysicsBody()->setCategoryBitmask(0x08); // 1000
|
||||
triangle->getPhysicsBody()->setContactTestBitmask(0x02); // 0010
|
||||
|
@ -1566,7 +1566,7 @@ void PhysicsPositionRotationTest::onEnter()
|
|||
|
||||
// anchor test
|
||||
auto anchorNode = Sprite::create("Images/YellowSquare.png");
|
||||
anchorNode->setAnchorPoint(Point(0.1, 0.9));
|
||||
anchorNode->setAnchorPoint(Point(0.1f, 0.9f));
|
||||
anchorNode->setPosition(100, 100);
|
||||
anchorNode->setScale(0.25);
|
||||
anchorNode->setPhysicsBody(PhysicsBody::createBox(anchorNode->getContentSize()*anchorNode->getScale()));
|
||||
|
|
|
@ -314,9 +314,9 @@ RenderTextureZbuffer::RenderTextureZbuffer()
|
|||
label3->setPosition(Point(size.width / 2, size.height * 0.75f));
|
||||
this->addChild(label3);
|
||||
|
||||
label->setVertexZ(50);
|
||||
label2->setVertexZ(0);
|
||||
label3->setVertexZ(-50);
|
||||
label->setPositionZ(50);
|
||||
label2->setPositionZ(0);
|
||||
label3->setPositionZ(-50);
|
||||
|
||||
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Images/bugs/circle.plist");
|
||||
mgr = SpriteBatchNode::create("Images/bugs/circle.png", 9);
|
||||
|
@ -341,15 +341,15 @@ RenderTextureZbuffer::RenderTextureZbuffer()
|
|||
mgr->addChild(sp8, 2);
|
||||
mgr->addChild(sp9, 1);
|
||||
|
||||
sp1->setVertexZ(400);
|
||||
sp2->setVertexZ(300);
|
||||
sp3->setVertexZ(200);
|
||||
sp4->setVertexZ(100);
|
||||
sp5->setVertexZ(0);
|
||||
sp6->setVertexZ(-100);
|
||||
sp7->setVertexZ(-200);
|
||||
sp8->setVertexZ(-300);
|
||||
sp9->setVertexZ(-400);
|
||||
sp1->setPositionZ(400);
|
||||
sp2->setPositionZ(300);
|
||||
sp3->setPositionZ(200);
|
||||
sp4->setPositionZ(100);
|
||||
sp5->setPositionZ(0);
|
||||
sp6->setPositionZ(-100);
|
||||
sp7->setPositionZ(-200);
|
||||
sp8->setPositionZ(-300);
|
||||
sp9->setPositionZ(-400);
|
||||
|
||||
sp9->setScale(2);
|
||||
sp9->setColor(Color3B::YELLOW);
|
||||
|
|
|
@ -1 +1 @@
|
|||
4bb0b2a6151e4910ea662bedd91a5be655ec05d1
|
||||
4d17613c96e30631ec5da21b2629fa3d0fc39f2d
|
|
@ -38,6 +38,7 @@ static std::function<Layer*()> createFunctions[] =
|
|||
{
|
||||
CL(TexturePVRv3Premult),
|
||||
|
||||
CL(TextureMipMap),
|
||||
CL(TextureMemoryAlloc),
|
||||
CL(TextureAlias),
|
||||
CL(TexturePVRMipMap),
|
||||
|
|
|
@ -285,7 +285,7 @@ TMXOrthoTest::TMXOrthoTest()
|
|||
Size CC_UNUSED s = map->getContentSize();
|
||||
CCLOG("ContentSize: %f, %f", s.width,s.height);
|
||||
|
||||
auto scale = ScaleBy::create(10, 0.1);
|
||||
auto scale = ScaleBy::create(10, 0.1f);
|
||||
auto back = scale->reverse();
|
||||
auto seq = Sequence::create(scale, back, NULL);
|
||||
auto repeat = RepeatForever::create(seq);
|
||||
|
@ -1086,7 +1086,7 @@ void TMXIsoVertexZ::repositionSprite(float dt)
|
|||
auto p = _tamara->getPosition();
|
||||
p = CC_POINT_POINTS_TO_PIXELS(p);
|
||||
float newZ = -(p.y+32) /16;
|
||||
_tamara->setVertexZ( newZ );
|
||||
_tamara->setPositionZ( newZ );
|
||||
}
|
||||
|
||||
void TMXIsoVertexZ::onEnter()
|
||||
|
@ -1132,7 +1132,7 @@ TMXOrthoVertexZ::TMXOrthoVertexZ()
|
|||
// can use any Sprite and it will work OK.
|
||||
auto layer = map->getLayer("trees");
|
||||
_tamara = layer->getTileAt(Point(0,11));
|
||||
CCLOG("%p vertexZ: %f", _tamara, _tamara->getVertexZ());
|
||||
CCLOG("%p vertexZ: %f", _tamara, _tamara->getPositionZ());
|
||||
_tamara->retain();
|
||||
|
||||
auto move = MoveBy::create(10, Point(400,450) * (1/CC_CONTENT_SCALE_FACTOR()));
|
||||
|
@ -1155,7 +1155,7 @@ void TMXOrthoVertexZ::repositionSprite(float dt)
|
|||
// map size: 12x12
|
||||
auto p = _tamara->getPosition();
|
||||
p = CC_POINT_POINTS_TO_PIXELS(p);
|
||||
_tamara->setVertexZ( -( (p.y+81) /81) );
|
||||
_tamara->setPositionZ( -( (p.y+81) /81) );
|
||||
}
|
||||
|
||||
void TMXOrthoVertexZ::onEnter()
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
#include "VisibleRect.h"
|
||||
|
||||
USING_NS_CC;
|
||||
|
||||
Rect VisibleRect::s_visibleRect;
|
||||
|
||||
void VisibleRect::lazyInit()
|
||||
|
|
|
@ -2,25 +2,24 @@
|
|||
#define __VISIBLERECT_H__
|
||||
|
||||
#include "cocos2d.h"
|
||||
USING_NS_CC;
|
||||
|
||||
class VisibleRect
|
||||
{
|
||||
public:
|
||||
static Rect getVisibleRect();
|
||||
static cocos2d::Rect getVisibleRect();
|
||||
|
||||
static Point left();
|
||||
static Point right();
|
||||
static Point top();
|
||||
static Point bottom();
|
||||
static Point center();
|
||||
static Point leftTop();
|
||||
static Point rightTop();
|
||||
static Point leftBottom();
|
||||
static Point rightBottom();
|
||||
static cocos2d::Point left();
|
||||
static cocos2d::Point right();
|
||||
static cocos2d::Point top();
|
||||
static cocos2d::Point bottom();
|
||||
static cocos2d::Point center();
|
||||
static cocos2d::Point leftTop();
|
||||
static cocos2d::Point rightTop();
|
||||
static cocos2d::Point leftBottom();
|
||||
static cocos2d::Point rightBottom();
|
||||
private:
|
||||
static void lazyInit();
|
||||
static Rect s_visibleRect;
|
||||
static cocos2d::Rect s_visibleRect;
|
||||
};
|
||||
|
||||
#endif /* __VISIBLERECT_H__ */
|
||||
|
|
|
@ -185,8 +185,8 @@ void ZwoptexGenericTest::flipSprites(float dt)
|
|||
char str2[32] = {0};
|
||||
sprintf(str1, "grossini_dance_%02d.png", spriteFrameIndex);
|
||||
sprintf(str2, "grossini_dance_generic_%02d.png", spriteFrameIndex);
|
||||
sprite1->setDisplayFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(str1));
|
||||
sprite2->setDisplayFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(str2));
|
||||
sprite1->setSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(str1));
|
||||
sprite2->setSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(str2));
|
||||
}
|
||||
|
||||
ZwoptexGenericTest::~ZwoptexGenericTest()
|
||||
|
|
|
@ -23,6 +23,8 @@ ELAPSEDSECS=`date +%s`
|
|||
COCOS_BRANCH="update_lua_bindings_$ELAPSEDSECS"
|
||||
COCOS_ROBOT_REMOTE="https://${GH_USER}:${GH_PASSWORD}@github.com/${GH_USER}/cocos2d-x.git"
|
||||
PULL_REQUEST_REPO="https://api.github.com/repos/cocos2d/cocos2d-x/pulls"
|
||||
FETCH_REMOTE_BRANCH="develop"
|
||||
COMMIT_PATH="cocos/scripting/lua-bindings/auto"
|
||||
|
||||
# Exit on error
|
||||
set -e
|
||||
|
@ -88,12 +90,14 @@ pushd "$PROJECT_ROOT"
|
|||
git status
|
||||
|
||||
echo
|
||||
echo Comparing with HEAD ...
|
||||
echo Comparing with origin HEAD ...
|
||||
echo
|
||||
|
||||
git fetch origin ${FETCH_REMOTE_BRANCH}
|
||||
|
||||
# Don't exit on non-zero return value
|
||||
set +e
|
||||
git diff --stat --exit-code
|
||||
git diff FETCH_HEAD --stat --exit-code ${COMMIT_PATH}
|
||||
|
||||
DIFF_RETVAL=$?
|
||||
if [ $DIFF_RETVAL -eq 0 ]
|
||||
|
|
|
@ -6,6 +6,8 @@ PROJECT_ROOT="$DIR"/../..
|
|||
COMMITTAG="[AUTO][ci skip]: updating cocos2dx_files.json"
|
||||
PUSH_REPO="https://api.github.com/repos/cocos2d/cocos2d-x/pulls"
|
||||
OUTPUT_FILE_PATH="${PROJECT_ROOT}/templates/cocos2dx_files.json"
|
||||
FETCH_REMOTE_BRANCH="develop"
|
||||
COMMIT_PATH="templates/cocos2dx_files.json"
|
||||
|
||||
# Exit on error
|
||||
set -e
|
||||
|
@ -51,12 +53,14 @@ pushd "$PROJECT_ROOT"
|
|||
git status
|
||||
|
||||
echo
|
||||
echo Comparing with HEAD ...
|
||||
echo Comparing with origin HEAD ...
|
||||
echo
|
||||
|
||||
git fetch origin ${FETCH_REMOTE_BRANCH}
|
||||
|
||||
# Don't exit on non-zero return value
|
||||
set +e
|
||||
git diff --stat --exit-code
|
||||
git diff FETCH_HEAD --stat --exit-code ${COMMIT_PATH}
|
||||
|
||||
DIFF_RETVAL=$?
|
||||
if [ $DIFF_RETVAL -eq 0 ]
|
||||
|
|
Loading…
Reference in New Issue