Optimized loop of ccArrayGetIndexOfObject to remove the overhead of 3
pointer dereferences per iteration, and pre-increment the int for
speed. If this function is called a lot, and with a large list, this
will result in a good performance win.
This can probably be done with just pointers, but I haven't taken the
time to validate all function calls to make sure it would be
appropriate. Though I can guarantee that if this worked fine before, it
will work fine with this change.
There's currently no way to be sure, from a calling function, that
fullPathForFilename has returned an invalid file path, which makes it
difficult to quickly track down missing, or incorrect file paths. Added
a CCLOG before the original string is returned to make debugging
missing or incorrect file paths easier.
fixed#1935: Float comparison must not use "==" in the equal function of CCPoint and CCSize, we should compare float number by using epsilon and absolute difference.
The ENABLE_BOX2D/ENABLE_CHIPMUNK defines were previously
hardcoded in the Makefiles. Now you get chipmunk by default
on both platforms and can enble Box2D by setting USE_BOX2D in
your environment.
Also remove erroneous -D__CC_PLATFORM_FILEUTILS_CPP__ and
-D__CC_PLATFORM_IMAGE_CPP__ from linux Makefiles. These should
never be defined globally like this.
CCPhysicsSprite was overriding only some of the getPosition
methods on a node resulting in, for example, getPositionX
and getPositionY not working for physics nodes.
This change also makes this overloads shared between box2d
and chipmunk implementations.
fixed#2030: Fixing a display bug when a scrollView nested in another scrollView. The parent's scissor rect need to be considered, when setting the scissor rect in the subScrollView.
When calling 'CCFileUtils::createCCDictionaryWithContentsOfFile' and 'CCFileUtils::createCCArrayWithContentsOfFile' on iOS/OSX these functions call upon 'CCFileUtils::fullPathForFilename' to resolve the path given into a full path which can be used with system file IO functions. This matches the convention found throughout the cocos2dx library and is expected behaviour. However, on Android and other platforms it appears calling 'CCFileUtils::createCCDictionaryWithContentsOfFile' or 'CCFileUtils:: createCCArrayWithContentsOfFile' does not do the same resolution using 'CCFileUtils::fullPathForFilename' - resulting in file paths which are correctly specified (and which worked on iOS/OSX) to fail to load on these platforms.
Fix this issue by performing a lookup/resolve of the file path using 'CCFileUtils::fullPathForFilename' before doing the low level loading work itself. This brings the behaviour of other platforms in line with iOS and OSX.
The character array which given to CCSAXParser::parse() may not be NULL
terminated.
Therefore we must also add the size of the data array to the parameter list
of the tinyxml2::XMLDocument::parse() call
face->size->metrics->ascender seems to be unreliable for some fonts,
additionally the freetype documentation says that it may be used
differently for different fonts.
Therefore it may happen that the ascender of a font face is less then
the glyphs bounding box resulting in accessing invalid memory.
The fix is to use the bbox attribute instead of the ascender
If the scheduler is the last object to have retained the pElements target and
the targets desctructor calls CCScheduler::unschedule() invalid memory is
accessed as pElement->timers is already freed, but the pElement is not removed
yet.
Therefore the call to target->release() should be made after pElement has been
removed from the hash table
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
First destroy CCDirector instance with cocos2d::CCDirector::sharedDirector()->end()
Then create new CCDirector instance with
cocos2d::CCApplication::sharedApplication()->run();
APP will crash at
CCApplication::setAnimationInterval
[[CCDirectorCaller sharedDirectorCaller] setAnimationInterval: interval ];
These new resolution policies will either ignore the width or height of the
specified design resolution size, but scale the ignored dimension, so it
matches the aspect ratio of the device.
Example:
A device with 854x480 pixels and a design resolution size set to 480x320
and the kResolutionFixedHeight policy, will create an internal canvas of
the size of 570x320px
If the device original size is 800x480 its internal size will be
534x320px
The height for both examples stays the same, the width is adjusted to match
the aspect ratio
Benefits:
- no distortions
- full canvas is usable, the visibility origin is 0/0
- I can use getWinSize() to place objects which is more intuitive
- for objects that should be placed at 0/0 I can use CGPointZero or 0/0 instead
of the VisibilityRect methods, which is more readable
- using this method projects from the 1.x branch are probably much easier to
port
Disadvantages:
- it is the developers responsibility to create the game code so that it
supports multiple aspect ratios
fixed#1837: Refactoring schedule binding codes.
1) We need bind cc.Node.scheduleUpdate and cc.Scheduler.scheduleUpdate manually since schedules need to be associated with _schedFunc_target_ht and _schedObj_target_ht.
2) Bind cc.Scheduler.unscheduleCallbackForTarget.
* 1) We need bind cc.Node.scheduleUpdate and cc.Scheduler.scheduleUpdate manually since `schedules` need to be associated with _schedFunc_target_ht and _schedObj_target_ht
* 2) Bind cc.Scheduler.unscheduleCallbackForTarget.
Some CCLog message contained trailing newlines which
made the logs hard to read on many platforms. The solution
here is to stip trailing newlines on those platforms, and also
to remove the newlines from the existing log messages.
fixed#1834: [Linux] fixed font rendering artifacts, added simple line break.
This patch fixed the size calculations for true type fonts (especially for
italic fonts)
Additinally a very simple greedy line break algorithm has been added for
true type labels.
This patch fixed the size calculations for true type fonts (especially for
italic fonts)
Additinally a very simple greedy line break algorithm has been added for
true type labels.
As FcFontMach is quite an expensive call the results of getFontFile() are
now cached in an std::map if either a ttf file is packed with the app or
if a font file has been found by using fontconfig
This is a helper method that removes all observers with a particular
target. It can be used in destuctors to ensure no observers trigger
callbacks on objects that no longer exist.
Also, a few other linux build system improvements:
- Add linux build of SimpleGame
- Update multi-platform templates to use new common
build system.
- Remove redundant main.h files.