Commit Graph

149 Commits

Author SHA1 Message Date
James Chen e6d2c4ec73 Refactors Scheduler class.
* Timer is an abstract class now.
* Adds three new timers ( `TimerTargetSelector`, `TimerTargetCallback`, `TimerScriptHandler`) which are inherited from Timer.
* Adds new API 'scheduleCallback` / `unscheduleCallbackForKey', and callback's target could be any classes since we're using `void*` to identify target.
* `Scheduler::scheduleCallback` use `std::function`, therefore, it supports passing `lambda`, `member_function` and `global_function`.
* The old selector API is still kept since it's very useful when schedule callback is a member function, it doesn't need a `key` to identify the callback function. (+1 squashed commit)
* Adds relevant test cases.
2014-03-01 14:09:09 +08:00
Ricardo Quesada 3588041409 removed empty spaces 2014-02-28 16:39:04 -08:00
Ricardo Quesada d78304599d Cache working OK.
Performance increased in 20% for static objects.
2014-02-28 16:10:48 -08:00
Ricardo Quesada 13b60c8759 Applies Wu Hao's patch for 2.5D 2014-02-28 13:48:00 -08:00
Ricardo Quesada 6920bec6ef transform object returns the MV
code cleaner.
the kmGL code is altogether
2014-02-28 11:20:53 -08:00
boyu0 a934d29c57 issue #4150: Correct body position with the node has a parent. Add set/getPosition/Rotation method. 2014-02-28 15:31:25 +08:00
Ricardo Quesada eb66ddd931 visit and draw improved.
`visit()` and `draw()` are improved.
they both receive:
 - `Renderer`
 - `kmMat4` for transformation
 - `bool` whether or not the transform changed from the previous frame

Although `draw` and `visit` are not using the 3 new parameters,
they will start using it in the coming days (or weeks, or months).

Those parameters are needed for:
 - `Renderer` shouldn't be a singleton. There should be one renderer per Director. There could be more than one renderer
 - we should get rid of `kmGLXXX` functions since nodoby knows what is happening. the `kmMat4` is for that.
 - whenever possible, we should try to optimize the multiplications. the `dirty` flag is for that.

We need those changes, so, it is better to change the API now, and not right after v3.0-final is released.
2014-02-27 21:43:54 -08:00
boyu0 8c536589df Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into iss4118_physical_performance_improve 2014-02-27 20:04:04 +08:00
minggo 8d47d5f16a return immediately when no changing 2014-02-27 15:12:57 +08:00
boyu0 b63641c7a5 issue #4118: delete physicsSetPosition/Rotation method and add physics position/rotation tag. 2014-02-27 14:36:09 +08:00
boyu0 f400c1ac68 issue #4118: edit contact test and fix node setPhysicsBody bug 2014-02-27 13:35:37 +08:00
boyu0 4df1e104f3 issue #4118: improve performance. 2014-02-26 19:56:52 +08:00
James Chen 5e315273f9 Merge pull request #5467 from boyu0/bug4144_node_setphysicsbody
closed #4144: fix bug: Can not use Node::setPhysicsBody to reset a physics body.
2014-02-26 11:43:19 +08:00
boyu0 912dad7a71 closed #4144: fix bug: Node::setPhysicsBody doesn't work at the second time. 2014-02-26 10:53:41 +08:00
boyu0 a4cc0edb4a issue #4118: refactor physics update 2014-02-24 16:17:42 +08:00
Ricardo Quesada fe1160cd8c changes in API to support 3D 2014-02-22 19:16:42 -08:00
James Chen 0d8846d876 closed #4097: Adds a macro to disable inserting script binding relevant codes. 2014-02-20 16:40:46 +08:00
James Chen 5e6130c92c issue #4058: Get rid of Object ,rename it to Ref. 2014-02-20 10:53:49 +08:00
Ricardo Quesada 7a8707cb08 Merge branch 'develop' into local_z_Order_fixes
Conflicts:
	cocos/2d/CCNode.cpp
	cocos/2d/CCNode.h
2014-01-21 10:10:50 -08:00
Ricardo Quesada f1444a26a1 Improves documentation with local z order 2014-01-21 09:26:58 -08:00
James Chen 0f9c3fa59c closed #3789: EventDispatcher supports sorting listeners by global Z and local Z order. And adds relevant test case. 2014-01-21 10:23:05 +08:00
James Chen 9f793f8a9b Warning fixes: 1) getZOrder —> getLocalZOrder. 2) long —> int 2014-01-20 15:03:30 +08:00
Ricardo Quesada 5fcbf42356 GlobalZOrder is used for render priority...
...and not vertexZ

Node::setGlobalZOrder() is used to change that.

Node::setZOrder() -> Node::setLocalZOrder();
2014-01-18 11:38:06 -08:00
Ricardo Quesada f2c3d2f3ae Camera and Node fixes
OrbitCamera: added getters (public). Setters moved from `protected` to `public
	: Improved API. Instead of using "out" parameters for getters, it returns a `kmVec3`
 	: Setters receives `kmVec3` as well. Old API is still supported

Node: `setAdditionalTransform` doesn't get `dirty` on the next frame.
	Instead, once the additional transform is set, in order to remove it the user needs to pass
	the identity matrix
2014-01-13 12:52:07 -08:00
walzer 64af0de648 update copyrights for 2014, in cocos/2d/ folder 2014-01-07 11:25:07 +08:00
Ricardo Quesada 5a0284c183 Node vertex Z fix
Node correctly  sets the Z vertex in getNodeToParentTransform(),
and not in transform().

This is the correct thing to do, and also fixes possible collisions
with the additionalTransform (eg: Camera)
2014-01-03 17:54:07 -08:00
Ricardo Quesada a7b33e3ec3 Fixes NodeToWorld
Multiplication was in the incorrect order
2014-01-03 14:21:33 -08:00
James Chen 200f07dc34 closed #3290: [JSB] The order of onEnter and onExit is wrong. For develop branch. 2013-12-30 11:10:02 +08:00
James Chen 9baa64f274 Merge pull request #4688 from walzer/develop
make CC_USE_PHYSICS can ACTUALLY be switch off
2013-12-27 04:04:48 -08:00
James Chen febc19ea8d Some warning fixes on linux. 2013-12-26 23:06:16 -08:00
walzer c5e95618d9 fixed #3517, make CC_USE_PHYSICS can be switch off, and bring Scene::update(float), Scene::addChild(...) out of CC_USE_PHYSICS segment 2013-12-26 23:55:05 +08:00
boyu0 3344c5243c change some const char* to const std::string& 2013-12-24 10:51:47 +08:00
Ricardo Quesada 4f435a8613 Adds getScene() to Node
helper function to get the Scene containing the Node
2013-12-21 12:28:49 -08:00
Ricardo Quesada d8ad5291f4 Nore camera 2013-12-20 16:33:31 -08:00
Ricardo Quesada 0703d974e2 NodeGrid fixes
Adds license
Removes unneded matrix
replaces std::for_each with for range-loop
2013-12-20 11:52:52 -08:00
minggo 756f8f7a11 Merge pull request #4482 from dabingnn/develop_gridNode
Develop grid node
2013-12-19 18:30:42 -08:00
Huabing.Xu 9fec597ff3 remove unreachable code 2013-12-19 21:36:44 +08:00
James Chen 3dc052db4f Fixes linux and windows building failure. 2013-12-19 20:32:22 +08:00
Huabing.Xu d51ad36613 Merge branch 'develop' into develop_gridNode
* develop: (67 commits)
  Adds const in ShaderTest2.h
  Skew works again!
  [AUTO] : updating submodule reference to latest autogenerated bindings
  [AUTO] : updating submodule reference to latest autogenerated bindings
  Reverts submodule.
  Updates submodule of bindings-generator.
  Adds `std::for_each` test in invocation
  Reverts bindings-generator.
  fixed not render
  iterator in Sprite fixes
  update vs project for removes unneeded files
  getNodeToParentTransform fixes
  Node cleanup
  [AUTO] : updating submodule reference to latest autogenerated bindings
  Improves SpriteTest
  [AUTO] : updating submodule reference to latest autogenerated bindings
  Android and Linux fixes
  removes `using namespace std` from header file
  Removes unneeded files
  change play arguments
  ...

Conflicts:
	cocos/2d/CCNode.cpp
	samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp
2013-12-19 17:20:22 +08:00
boyu0 ef54ed3c15 Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into HEAD
Conflicts:
	cocos/2d/CCLabel.cpp
	cocos/2d/CCLabel.h
	cocos/2d/CCLabelBMFont.cpp
	cocos/2d/CCLabelBMFont.h
	cocos/2d/CCLayer.cpp
	cocos/2d/CCLayer.h
	cocos/2d/CCNode.cpp
	extensions/GUI/CCControlExtension/CCControl.cpp
	extensions/GUI/CCControlExtension/CCControlButton.cpp
	extensions/GUI/CCControlExtension/CCScale9Sprite.cpp
	tools/tojs/cocos2dx.ini
2013-12-19 17:05:59 +08:00
Ricardo Quesada 1d3cc7a24c Skew works again! 2013-12-18 21:11:06 -08:00
Ricardo Quesada d138925aa0 Merge branch 'develop' into node_fixes 2013-12-18 18:33:56 -08:00
Ricardo Quesada b9a64725ab iterator in Sprite fixes
And replaces some std::for_each() with for() to prevent another object in the stack.
2013-12-18 18:33:04 -08:00
minggo 9fc28e6c7d Merge pull request #4534 from boyu0/edit_hungarian_notation
Edit hungarian notation
2013-12-18 18:10:17 -08:00
Ricardo Quesada 89701f5006 getNodeToParentTransform fixes
Code is cleaner.
`Armature` calls parent to reduce code.

[]: Skew is still not working properly
2013-12-18 18:00:55 -08:00
boyu0 c6cc77e75b Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into edit_hungarian_notation 2013-12-19 09:45:21 +08:00
Ricardo Quesada 8390e7eadb Node cleanup
Uses "normal" interation without the lambda to prevent another object in the stack.

removed unused code.
2013-12-18 16:56:59 -08:00
boyu0 082c3d274a Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into edit_hungarian_notation 2013-12-18 18:05:30 +08:00
boyu0 e07c4ffec1 Change NULL to nullptr, edit hungarian notation. 2013-12-18 17:47:20 +08:00
Dhilan007 2d9b7ee4fc update vs project for new renderer and fix compiling fail on vs. 2013-12-18 14:36:49 +08:00
Huabing.Xu 25fc3d3c2a Merge branch 'develop' into develop_gridNode
* develop: (105 commits)
  update armature to new render
  iOS & Mac project fix.
  [AUTO] : updating submodule reference to latest autogenerated bindings
  use size_t replace unsigned int for record redeque::size returned value.
  issue #2171: Updates CMakeLists.txt.
  issue #2171: Binds New renderer classes, ignores NewTextureAtlas.
  issue #2171: Adds header files of renderer in cocos2d.h.
  issue #2171: Reorder renderer files for iOS & mac project.
  issue #2171: small fix in ccTypes.h
  issue #2171: Don’t ‘using namespace std;’ in header file.
  [AUTO] : updating submodule reference to latest autogenerated bindings
  issue #2171: Ignores Director::getFrustum.
  issue #2171: Fixing compilation errors for Linux port.
  issue #2171: NULL —> nullptr for Android warning of CCBAnimationManager.cpp.
  issue #2171: [New Renderer] Fixing compilation errors for Android.
  [Win32] fix argument type. - argument of interface is ssize_t.
  Update AUTHORS [ci skip]
  Update CHANGELOG [ci skip]
  Add mouse scrolling support for extension test
  issue #3341:fix Incorrect at TextureCache::addImageAsync for repeatedly execute for the same image
  ...

Conflicts:
	cocos/2d/CCNode.cpp
	cocos/2d/cocos2d.vcxproj.filters
	samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp
2013-12-17 18:16:05 +08:00
James Chen d16fa07661 Removes Vector<T>::forEach, please use std::for_each instead. The same as Vector<T>::sort. 2013-12-17 17:45:29 +08:00
James Chen 2a38d4fe94 issue #2171: Fixing compilation errors for Linux port. 2013-12-17 14:50:40 +08:00
Huabing.Xu b1eacd52cb Merge branch 'develop' into develop_gridNode
* develop:
  fix compile error related to ssize_t.
  issue #2771: add and change some physics API, and add more documents
  [AUTO] : updating submodule reference to latest autogenerated bindings
  Some fixes for XXX:getDescription.
  Reverts CCSpriteBatchNode.h
  size_t —> ssize_t in CCTMXLayer.cpp
  issue #2771: add PhysicsWorld function set/getUpdateRate and set/getSpeed. Change name PhysicsQueryRectCallbackFunc and PhysicsPointQueryCallbackFunc to PhysicsRectQueryCallbackFunc and PhysicsQueryPointCallbackFunc
  Fix:Add lua binding of ’registerScriptHandler’、’unregisterScriptHandler’ and ’removeObjectAllHandlers’ of ScriptHandlerMgr and some constants define
  [AUTO] : updating submodule reference to latest autogenerated bindings
  More renames of description() to getDescription()
  getDescription() works as expected
  fix compiling error after fixing conflicts
  fix compiling error after fixing conflicts
  use ssize_t for index
  use ssize_t for index and capacity
  use ssize_t for capacity and index in containers
  Fix:Remove some needless lua binding functions and resolve a bug
2013-12-16 10:43:49 +08:00
boyu0 f9f816caf9 issue #3162: change log to cpp file 2013-12-16 03:42:54 +08:00
Ricardo Quesada 3838268fd0 Merge branch 'develop' into newRenderer 2013-12-14 19:28:01 -08:00
boyu0 defae416f3 Merge branch 'develop' of git://github.com/cocos2d/cocos2d-x into bug3162_opacity_incorrect 2013-12-13 18:09:39 +08:00
James Chen bb5ef615dd Merge branch 'develop' of git://github.com/cocos2d/cocos2d-x into pr4479
Conflicts:
	cocos/2d/CCSpriteBatchNode.h
2013-12-13 16:44:22 +08:00
boyu0 d4c8fb0be6 Merge branch 'develop' of git://github.com/cocos2d/cocos2d-x into bug3162_opacity_incorrect 2013-12-13 10:47:52 +08:00
Ricardo Quesada 61cc365d9e Merge branch 'develop' into newRenderer
Conflicts:
	cocos/2d/CCGLProgram.h
	cocos/2d/CCLabelTTF.h
2013-12-12 14:41:42 -08:00
Ricardo Quesada a8c317bd83 getDescription() works as expected
renames `description` to `getDescription`. Adds `virtual`  to it.
Adds `getDescription` to missing nodes.
2013-12-12 14:30:22 -08:00
Ricardo Quesada 29a15c885a Merge branch 'develop' into newRenderer 2013-12-12 11:44:09 -08:00
boyu0 d7106d49be Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into bug3162_opacity_incorrect 2013-12-12 17:04:21 +08:00
Huabing.Xu 5509bd48ef remove _grid 2013-12-12 16:21:21 +08:00
Huabing.Xu 09a9b1f557 remove setGrid getGrid in class Node 2013-12-12 15:15:43 +08:00
minggo 1e9c763b40 use ssize_t for index and capacity 2013-12-12 14:48:26 +08:00
James Chen b2e8bdce1e issue #2790: Uses StringUtils::format for Node::description(). 2013-12-12 09:47:35 +08:00
James Chen cc567a3077 issue #2790: Vector::remove —> Vector::erase. 2013-12-11 18:08:06 +08:00
James Chen be9bb6998b issue #2790: Deprecates Dictionary, Array, String, Integer, Bool, Float, Double classes.
Also renames Map::remove to Map::erase.
2013-12-11 18:08:06 +08:00
boyu0 463ae20ce6 issue #3162: Add layer cascade color and cascade opacity test, fix bugs 2013-12-11 15:57:20 +08:00
Ricardo Quesada 23222923bf Migrated code to Matrix4 2013-12-10 11:07:15 -08:00
Ricardo Quesada 0222c6544e Migration to Mat4x4
Armature not migrated yet

Signed-off-by: Ricardo Quesada <ricardoquesada@gmail.com>
2013-12-09 17:32:51 -08:00
Ricardo Quesada ee0ef6bf46 ProgressTimer works OK
Adds _modelViewTransform as  ivar of Node (temporary fix)
2013-12-06 17:42:16 -08:00
boyu0 0e94d4f3b8 closed #3162: fix indent. 2013-12-06 18:23:31 +08:00
boyu0 4d0e3dbd8d Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into bug3162_opacity_incorrect 2013-12-06 18:16:26 +08:00
boyu0 af5f496861 issue #3162: Merge Node and NodeRGBA, fix bug: Child's opacity will not be changed when its parent's setCascadeOpacityEnabled was set to true and opacity was changed. 2013-12-06 18:07:16 +08:00
minggo b67d567a79 replace long with int or ssize_t 2013-12-05 17:22:22 +08:00
James Chen 499a0404d4 issue #2790: Renames some functions in Vector<T>. Makes it more like stl vector. 2013-12-05 10:35:10 +08:00
James Chen ceaa1f26bb issue #2790: Windows run ok with ValueDict for FileUtils. 2013-12-04 16:02:54 +08:00
James Chen 9928e8bef1 issue #2790: Uses Vector<T>::getObjectAtIndex instead of Vector<T>[] operator to avoid some mistakes. 2013-12-04 16:01:55 +08:00
James Chen 1d5984b29a issue #2790: Vector::makeObjectsPerformCallback —> Vector::forEach 2013-12-04 16:01:02 +08:00
James Chen d4d864216b issue #2790: Deletes Vector::init, adds Vector::setCapacity. 2013-12-04 16:00:18 +08:00
James Chen 90062b656d issue #2790: Node::_children is Vector<Node*> now. 2013-12-04 16:00:17 +08:00
boyu0 fd68dc4f9f issue #2771: add condition test to updatePhysicsTransform 2013-12-03 16:28:18 +08:00
minggo a057274115 set z order after reorder 2013-11-14 14:08:50 +08:00
Ricardo Quesada ba7ed6e578 Fixes some compiler warnings
The warnings are related to:

* 64-to-32-bit conversion
* shadow variables
2013-11-04 16:31:36 -08:00
boyu0 2f67ceb495 issue #2771: fix some code style 2013-11-01 16:26:03 +08:00
boyu0 e8d06496d0 Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into iss2771_physical 2013-10-30 17:27:09 +08:00
boyu0 66d1bbd89f issue #2771: edit physics effect with all bodies and fix some bugs 2013-10-28 16:17:19 +08:00
boyu0 d0d8694091 issue #2771: fix some retain/release bugs 2013-10-28 11:08:41 +08:00
James Chen 48ce5e39fe EventDispatcher is managed by Director now, like Scheduler and ActionManager. 2013-10-26 15:04:01 +08:00
James Chen c4f9acbee7 disable DUMP_LISTENER_ITEM_PRIORITY_INFO. use std::unordered_map instead of std::map. 2013-10-25 10:53:47 +08:00
James Chen dc6e201eb6 bug fix for eventdispatcher. 2013-10-25 10:53:46 +08:00
James Chen 1f3863e787 Event Dispatcher refactor commit. TestCpp could run. 2013-10-25 10:53:45 +08:00
James Chen f7e2c63230 Refactor event dispatcher. Remove non-node relative member variables. 2013-10-25 10:53:45 +08:00
James Chen cfaef2a01a Adding onEnterHook, onXXXHook for Node. 2013-10-25 10:53:45 +08:00
boyu0 d12ee5f120 Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into iss2771_physical 2013-10-18 15:34:13 +08:00
minggo 95acb1b9e3 issue #2905: helloworld build ok on android 2013-10-14 14:01:00 +08:00
minggo 49d7bbd600 issue #2905: remove sub folders except platform 2013-10-12 15:41:45 +08:00