mirror of https://github.com/axmolengine/axmol.git
Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into skipComponentFns
This commit is contained in:
commit
25e047eb41
|
@ -74,8 +74,7 @@ void Component::onEnter()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendComponentEventToJS(this, kComponentOnEnter))
|
||||
return;
|
||||
sendComponentEventToJS(this, kComponentOnEnter);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -85,8 +84,27 @@ void Component::onExit()
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendComponentEventToJS(this, kComponentOnExit))
|
||||
return;
|
||||
sendComponentEventToJS(this, kComponentOnExit);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Component::onAdd()
|
||||
{
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
sendComponentEventToJS(this, kComponentOnAdd);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Component::onRemove()
|
||||
{
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
sendComponentEventToJS(this, kComponentOnRemove);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -96,8 +114,7 @@ void Component::update(float delta)
|
|||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
if (sendComponentEventToJS(this, kComponentOnUpdate))
|
||||
return;
|
||||
sendComponentEventToJS(this, kComponentOnUpdate);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ class Node;
|
|||
enum {
|
||||
kComponentOnEnter,
|
||||
kComponentOnExit,
|
||||
kComponentOnAdd,
|
||||
kComponentOnRemove,
|
||||
kComponentOnUpdate
|
||||
};
|
||||
|
||||
|
@ -58,6 +60,8 @@ public:
|
|||
|
||||
virtual void onEnter();
|
||||
virtual void onExit();
|
||||
virtual void onAdd();
|
||||
virtual void onRemove();
|
||||
virtual void update(float delta);
|
||||
virtual bool serialize(void* r);
|
||||
virtual bool isEnabled() const;
|
||||
|
|
|
@ -68,7 +68,7 @@ bool ComponentContainer::add(Component *com)
|
|||
CC_BREAK_IF(component);
|
||||
com->setOwner(_owner);
|
||||
_components->insert(com->getName(), com);
|
||||
com->onEnter();
|
||||
com->onAdd();
|
||||
ret = true;
|
||||
} while(0);
|
||||
return ret;
|
||||
|
@ -85,7 +85,7 @@ bool ComponentContainer::remove(const std::string& name)
|
|||
CC_BREAK_IF(iter == _components->end());
|
||||
|
||||
auto com = iter->second;
|
||||
com->onExit();
|
||||
com->onRemove();
|
||||
com->setOwner(nullptr);
|
||||
|
||||
_components->erase(iter);
|
||||
|
@ -105,7 +105,7 @@ bool ComponentContainer::remove(Component *com)
|
|||
{
|
||||
if (iter->second == com)
|
||||
{
|
||||
com->onExit();
|
||||
com->onRemove();
|
||||
com->setOwner(nullptr);
|
||||
_components->erase(iter);
|
||||
break;
|
||||
|
@ -122,7 +122,7 @@ void ComponentContainer::removeAll()
|
|||
{
|
||||
for (auto iter = _components->begin(); iter != _components->end(); ++iter)
|
||||
{
|
||||
iter->second->onExit();
|
||||
iter->second->onRemove();
|
||||
iter->second->setOwner(nullptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -1419,6 +1419,11 @@ void Node::onEnter()
|
|||
if (_onEnterCallback)
|
||||
_onEnterCallback();
|
||||
|
||||
if (_componentContainer && !_componentContainer->isEmpty())
|
||||
{
|
||||
_componentContainer->onEnter();
|
||||
}
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
|
@ -1498,6 +1503,11 @@ void Node::onExit()
|
|||
if (_onExitCallback)
|
||||
_onExitCallback();
|
||||
|
||||
if (_componentContainer && !_componentContainer->isEmpty())
|
||||
{
|
||||
_componentContainer->onExit();
|
||||
}
|
||||
|
||||
#if CC_ENABLE_SCRIPT_BINDING
|
||||
if (_scriptType == kScriptTypeJavascript)
|
||||
{
|
||||
|
|
|
@ -56,6 +56,16 @@ void ComAudio::onExit()
|
|||
stopAllEffects();
|
||||
}
|
||||
|
||||
void ComAudio::onAdd()
|
||||
{
|
||||
}
|
||||
|
||||
void ComAudio::onRemove()
|
||||
{
|
||||
stopBackgroundMusic(true);
|
||||
stopAllEffects();
|
||||
}
|
||||
|
||||
bool ComAudio::isEnabled() const
|
||||
{
|
||||
return _enabled;
|
||||
|
|
|
@ -59,6 +59,16 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual void onExit() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onAdd() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onRemove() override;
|
||||
virtual bool isEnabled() const override;
|
||||
virtual void setEnabled(bool b) override;
|
||||
virtual bool serialize(void* r) override;
|
||||
|
|
|
@ -54,6 +54,18 @@ void ComController::onExit()
|
|||
{
|
||||
}
|
||||
|
||||
void ComController::onAdd()
|
||||
{
|
||||
if (_owner != nullptr)
|
||||
{
|
||||
_owner->scheduleUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
void ComController::onRemove()
|
||||
{
|
||||
}
|
||||
|
||||
void ComController::update(float delta)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -59,6 +59,16 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual void onExit() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onAdd() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onRemove() override;
|
||||
virtual void update(float delta) override;
|
||||
virtual bool isEnabled() const override;
|
||||
virtual void setEnabled(bool b) override;
|
||||
|
|
|
@ -68,6 +68,22 @@ void ComRender::onExit()
|
|||
}
|
||||
}
|
||||
|
||||
void ComRender::onAdd()
|
||||
{
|
||||
if (_owner != nullptr)
|
||||
{
|
||||
_owner->addChild(_render);
|
||||
}
|
||||
}
|
||||
|
||||
void ComRender::onRemove()
|
||||
{
|
||||
if (_owner != nullptr)
|
||||
{
|
||||
_owner->removeChild(_render, true);
|
||||
}
|
||||
}
|
||||
|
||||
cocos2d::Node* ComRender::getNode()
|
||||
{
|
||||
return _render;
|
||||
|
|
|
@ -57,6 +57,16 @@ public:
|
|||
* @lua NA
|
||||
*/
|
||||
virtual void onExit() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onAdd() override;
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual void onRemove() override;
|
||||
virtual bool serialize(void* r) override;
|
||||
virtual cocos2d::Node* getNode();
|
||||
virtual void setNode(cocos2d::Node *node);
|
||||
|
|
|
@ -28,6 +28,8 @@ import java.io.DataInputStream;
|
|||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
|
@ -260,11 +262,20 @@ public class Cocos2dxHttpURLConnection
|
|||
}
|
||||
|
||||
static byte[] getResponseContent(HttpURLConnection http) {
|
||||
DataInputStream in;
|
||||
try {
|
||||
in = new DataInputStream(http.getInputStream());
|
||||
InputStream in;
|
||||
try {
|
||||
in = http.getInputStream();
|
||||
String contentEncoding = http.getContentEncoding();
|
||||
if (contentEncoding != null) {
|
||||
if(contentEncoding.equalsIgnoreCase("gzip")){
|
||||
in = new GZIPInputStream(http.getInputStream()); //reads 2 bytes to determine GZIP stream!
|
||||
}
|
||||
else if(contentEncoding.equalsIgnoreCase("deflate")){
|
||||
in = new InflaterInputStream(http.getInputStream());
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
in = new DataInputStream(http.getErrorStream());
|
||||
in = http.getErrorStream();
|
||||
} catch (Exception e) {
|
||||
Log.e("Cocos2dxHttpURLConnection exception", e.toString());
|
||||
return null;
|
||||
|
|
|
@ -22213,6 +22213,14 @@ isEnabled : function (
|
|||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method onRemove
|
||||
*/
|
||||
onRemove : function (
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method update
|
||||
* @param {float} arg0
|
||||
|
@ -22244,11 +22252,9 @@ init : function (
|
|||
},
|
||||
|
||||
/**
|
||||
* @method setOwner
|
||||
* @param {cc.Node} arg0
|
||||
* @method onAdd
|
||||
*/
|
||||
setOwner : function (
|
||||
node
|
||||
onAdd : function (
|
||||
)
|
||||
{
|
||||
},
|
||||
|
@ -22263,6 +22269,16 @@ getName : function (
|
|||
return ;
|
||||
},
|
||||
|
||||
/**
|
||||
* @method setOwner
|
||||
* @param {cc.Node} arg0
|
||||
*/
|
||||
setOwner : function (
|
||||
node
|
||||
)
|
||||
{
|
||||
},
|
||||
|
||||
/**
|
||||
* @method create
|
||||
* @return {cc.Component}
|
||||
|
|
|
@ -67823,6 +67823,22 @@ bool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
JS_ReportError(cx, "js_cocos2dx_Component_isEnabled : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_onRemove(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_onRemove : Invalid Native Object");
|
||||
if (argc == 0) {
|
||||
cobj->onRemove();
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_onRemove : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_update(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
@ -67886,6 +67902,40 @@ bool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
JS_ReportError(cx, "js_cocos2dx_Component_init : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_onAdd(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_onAdd : Invalid Native Object");
|
||||
if (argc == 0) {
|
||||
cobj->onAdd();
|
||||
args.rval().setUndefined();
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_onAdd : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_getName : Invalid Native Object");
|
||||
if (argc == 0) {
|
||||
const std::string& ret = cobj->getName();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
jsret = std_string_to_jsval(cx, ret);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_getName : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
@ -67914,24 +67964,6 @@ bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp)
|
|||
JS_ReportError(cx, "js_cocos2dx_Component_setOwner : wrong number of arguments: %d, was expecting %d", argc, 1);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
JS::RootedObject obj(cx, args.thisv().toObjectOrNull());
|
||||
js_proxy_t *proxy = jsb_get_js_proxy(obj);
|
||||
cocos2d::Component* cobj = (cocos2d::Component *)(proxy ? proxy->ptr : NULL);
|
||||
JSB_PRECONDITION2( cobj, cx, false, "js_cocos2dx_Component_getName : Invalid Native Object");
|
||||
if (argc == 0) {
|
||||
const std::string& ret = cobj->getName();
|
||||
jsval jsret = JSVAL_NULL;
|
||||
jsret = std_string_to_jsval(cx, ret);
|
||||
args.rval().set(jsret);
|
||||
return true;
|
||||
}
|
||||
|
||||
JS_ReportError(cx, "js_cocos2dx_Component_getName : wrong number of arguments: %d, was expecting %d", argc, 0);
|
||||
return false;
|
||||
}
|
||||
bool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp)
|
||||
{
|
||||
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
|
||||
|
@ -68026,11 +68058,13 @@ void js_register_cocos2dx_Component(JSContext *cx, JS::HandleObject global) {
|
|||
JS_FN("setEnabled", js_cocos2dx_Component_setEnabled, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("setName", js_cocos2dx_Component_setName, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("isEnabled", js_cocos2dx_Component_isEnabled, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("onRemove", js_cocos2dx_Component_onRemove, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("update", js_cocos2dx_Component_update, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("getOwner", js_cocos2dx_Component_getOwner, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("init", js_cocos2dx_Component_init, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("setOwner", js_cocos2dx_Component_setOwner, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("onAdd", js_cocos2dx_Component_onAdd, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("getName", js_cocos2dx_Component_getName, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("setOwner", js_cocos2dx_Component_setOwner, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FN("ctor", js_cocos2d_Component_ctor, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
|
||||
JS_FS_END
|
||||
};
|
||||
|
|
|
@ -3922,11 +3922,13 @@ void register_all_cocos2dx(JSContext* cx, JS::HandleObject obj);
|
|||
bool js_cocos2dx_Component_setEnabled(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_setName(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_isEnabled(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_onRemove(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_update(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_getOwner(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_init(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_onAdd(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_getName(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_setOwner(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_create(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
bool js_cocos2dx_Component_Component(JSContext *cx, uint32_t argc, jsval *vp);
|
||||
|
||||
|
|
|
@ -1058,7 +1058,21 @@ int ScriptingCore::handleComponentEvent(void* data)
|
|||
JS::RootedValue retval(_cx);
|
||||
jsval dataVal = INT_TO_JSVAL(1);
|
||||
|
||||
if (action == kComponentOnEnter)
|
||||
if (action == kComponentOnAdd)
|
||||
{
|
||||
if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onAdd", js_cocos2dx_Component_onEnter))
|
||||
{
|
||||
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onAdd", 1, &dataVal, &retval);
|
||||
}
|
||||
}
|
||||
else if (action == kComponentOnRemove)
|
||||
{
|
||||
if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onRemove", js_cocos2dx_Component_onExit))
|
||||
{
|
||||
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "onRemove", 1, &dataVal, &retval);
|
||||
}
|
||||
}
|
||||
else if (action == kComponentOnEnter)
|
||||
{
|
||||
if (isFunctionOverridedInJS(JS::RootedObject(_cx, p->obj.get()), "onEnter", js_cocos2dx_Component_onEnter))
|
||||
{
|
||||
|
|
|
@ -951,11 +951,7 @@ void __JSDownloaderDelegator::startDownload()
|
|||
|
||||
cocos2d::extension::Downloader::HeaderInfo info = _downloader->getHeader(_url);
|
||||
long contentSize = info.contentSize;
|
||||
if (contentSize == -1 || info.responseCode >= 400) {
|
||||
cocos2d::extension::Downloader::Error err;
|
||||
onError(err);
|
||||
}
|
||||
else {
|
||||
if (contentSize > 0 && info.responseCode < 400) {
|
||||
_size = contentSize / sizeof(unsigned char);
|
||||
_buffer = (unsigned char*)malloc(contentSize);
|
||||
_downloader->downloadToBufferSync(_url, _buffer, _size);
|
||||
|
|
|
@ -199,12 +199,6 @@
|
|||
-- @param #bool b
|
||||
-- @return ComAudio#ComAudio self (return value: ccs.ComAudio)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#ComAudio] isEnabled
|
||||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#ComAudio] serialize
|
||||
|
@ -212,10 +206,30 @@
|
|||
-- @param #void r
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#ComAudio] isEnabled
|
||||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- js NA<br>
|
||||
-- lua NA
|
||||
-- @function [parent=#ComAudio] onRemove
|
||||
-- @param self
|
||||
-- @return ComAudio#ComAudio self (return value: ccs.ComAudio)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#ComAudio] init
|
||||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- js NA<br>
|
||||
-- lua NA
|
||||
-- @function [parent=#ComAudio] onAdd
|
||||
-- @param self
|
||||
-- @return ComAudio#ComAudio self (return value: ccs.ComAudio)
|
||||
|
||||
return nil
|
||||
|
|
|
@ -29,6 +29,13 @@
|
|||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- js NA<br>
|
||||
-- lua NA
|
||||
-- @function [parent=#ComController] onRemove
|
||||
-- @param self
|
||||
-- @return ComController#ComController self (return value: ccs.ComController)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#ComController] update
|
||||
|
@ -42,6 +49,13 @@
|
|||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- js NA<br>
|
||||
-- lua NA
|
||||
-- @function [parent=#ComController] onAdd
|
||||
-- @param self
|
||||
-- @return ComController#ComController self (return value: ccs.ComController)
|
||||
|
||||
--------------------------------
|
||||
-- js ctor
|
||||
-- @function [parent=#ComController] ComController
|
||||
|
|
|
@ -39,4 +39,18 @@
|
|||
-- @param #void r
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- js NA<br>
|
||||
-- lua NA
|
||||
-- @function [parent=#ComRender] onRemove
|
||||
-- @param self
|
||||
-- @return ComRender#ComRender self (return value: ccs.ComRender)
|
||||
|
||||
--------------------------------
|
||||
-- js NA<br>
|
||||
-- lua NA
|
||||
-- @function [parent=#ComRender] onAdd
|
||||
-- @param self
|
||||
-- @return ComRender#ComRender self (return value: ccs.ComRender)
|
||||
|
||||
return nil
|
||||
|
|
|
@ -24,6 +24,12 @@
|
|||
-- @param self
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Component] onRemove
|
||||
-- @param self
|
||||
-- @return Component#Component self (return value: cc.Component)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Component] update
|
||||
|
@ -45,9 +51,8 @@
|
|||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Component] setOwner
|
||||
-- @function [parent=#Component] onAdd
|
||||
-- @param self
|
||||
-- @param #cc.Node pOwner
|
||||
-- @return Component#Component self (return value: cc.Component)
|
||||
|
||||
--------------------------------
|
||||
|
@ -56,6 +61,13 @@
|
|||
-- @param self
|
||||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Component] setOwner
|
||||
-- @param self
|
||||
-- @param #cc.Node pOwner
|
||||
-- @return Component#Component self (return value: cc.Component)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- @function [parent=#Component] create
|
||||
|
|
|
@ -91234,6 +91234,53 @@ int lua_cocos2dx_Component_isEnabled(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_Component_onRemove(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::Component* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_onRemove'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 0)
|
||||
{
|
||||
if(!ok)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_onRemove'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
cobj->onRemove();
|
||||
lua_settop(tolua_S, 1);
|
||||
return 1;
|
||||
}
|
||||
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:onRemove",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_onRemove'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_Component_update(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
|
@ -91378,7 +91425,7 @@ int lua_cocos2dx_Component_init(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_Component_setOwner(lua_State* tolua_S)
|
||||
int lua_cocos2dx_Component_onAdd(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::Component* cobj = nullptr;
|
||||
|
@ -91398,32 +91445,29 @@ int lua_cocos2dx_Component_setOwner(lua_State* tolua_S)
|
|||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_setOwner'", nullptr);
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_onAdd'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 1)
|
||||
if (argc == 0)
|
||||
{
|
||||
cocos2d::Node* arg0;
|
||||
|
||||
ok &= luaval_to_object<cocos2d::Node>(tolua_S, 2, "cc.Node",&arg0, "cc.Component:setOwner");
|
||||
if(!ok)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_setOwner'", nullptr);
|
||||
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_onAdd'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
cobj->setOwner(arg0);
|
||||
cobj->onAdd();
|
||||
lua_settop(tolua_S, 1);
|
||||
return 1;
|
||||
}
|
||||
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:setOwner",argc, 1);
|
||||
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:onAdd",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_setOwner'.",&tolua_err);
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_onAdd'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -91475,6 +91519,56 @@ int lua_cocos2dx_Component_getName(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_Component_setOwner(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::Component* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.Component",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::Component*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Component_setOwner'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 1)
|
||||
{
|
||||
cocos2d::Node* arg0;
|
||||
|
||||
ok &= luaval_to_object<cocos2d::Node>(tolua_S, 2, "cc.Node",&arg0, "cc.Component:setOwner");
|
||||
if(!ok)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_Component_setOwner'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
cobj->setOwner(arg0);
|
||||
lua_settop(tolua_S, 1);
|
||||
return 1;
|
||||
}
|
||||
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Component:setOwner",argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Component_setOwner'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_Component_create(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
|
@ -91524,11 +91618,13 @@ int lua_register_cocos2dx_Component(lua_State* tolua_S)
|
|||
tolua_function(tolua_S,"setEnabled",lua_cocos2dx_Component_setEnabled);
|
||||
tolua_function(tolua_S,"setName",lua_cocos2dx_Component_setName);
|
||||
tolua_function(tolua_S,"isEnabled",lua_cocos2dx_Component_isEnabled);
|
||||
tolua_function(tolua_S,"onRemove",lua_cocos2dx_Component_onRemove);
|
||||
tolua_function(tolua_S,"update",lua_cocos2dx_Component_update);
|
||||
tolua_function(tolua_S,"getOwner",lua_cocos2dx_Component_getOwner);
|
||||
tolua_function(tolua_S,"init",lua_cocos2dx_Component_init);
|
||||
tolua_function(tolua_S,"setOwner",lua_cocos2dx_Component_setOwner);
|
||||
tolua_function(tolua_S,"onAdd",lua_cocos2dx_Component_onAdd);
|
||||
tolua_function(tolua_S,"getName",lua_cocos2dx_Component_getName);
|
||||
tolua_function(tolua_S,"setOwner",lua_cocos2dx_Component_setOwner);
|
||||
tolua_function(tolua_S,"create", lua_cocos2dx_Component_create);
|
||||
tolua_endmodule(tolua_S);
|
||||
std::string typeName = typeid(cocos2d::Component).name();
|
||||
|
|
|
@ -2049,6 +2049,8 @@ int register_all_cocos2dx(lua_State* tolua_S);
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -288,6 +288,7 @@ Downloader::HeaderInfo Downloader::prepareHeader(const std::string &srcUrl, void
|
|||
curl_easy_setopt(header, CURLOPT_URL, srcUrl.c_str());
|
||||
curl_easy_setopt(header, CURLOPT_HEADER, 1);
|
||||
curl_easy_setopt(header, CURLOPT_NOBODY, 1);
|
||||
curl_easy_setopt(header, CURLOPT_NOSIGNAL, 1);
|
||||
if (curl_easy_perform(header) == CURLE_OK)
|
||||
{
|
||||
char *url;
|
||||
|
@ -296,16 +297,24 @@ Downloader::HeaderInfo Downloader::prepareHeader(const std::string &srcUrl, void
|
|||
curl_easy_getinfo(header, CURLINFO_CONTENT_TYPE, &contentType);
|
||||
curl_easy_getinfo(header, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &info.contentSize);
|
||||
curl_easy_getinfo(header, CURLINFO_RESPONSE_CODE, &info.responseCode);
|
||||
info.url = url;
|
||||
info.contentType = contentType;
|
||||
info.valid = true;
|
||||
|
||||
if (_onHeader)
|
||||
if (contentType == nullptr || info.contentSize == -1 || info.responseCode >= 400)
|
||||
{
|
||||
_onHeader(srcUrl, info);
|
||||
info.valid = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
info.url = url;
|
||||
info.contentType = contentType;
|
||||
info.valid = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (info.valid && _onHeader)
|
||||
{
|
||||
_onHeader(srcUrl, info);
|
||||
}
|
||||
else if (!info.valid)
|
||||
{
|
||||
info.contentSize = -1;
|
||||
std::string msg = StringUtils::format("Can not get content size of file (%s) : Request header failed", srcUrl.c_str());
|
||||
|
|
|
@ -18,9 +18,9 @@ bool EnemyController::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void EnemyController::onEnter()
|
||||
void EnemyController::onAdd()
|
||||
{
|
||||
ComController::onEnter();
|
||||
ComController::onAdd();
|
||||
// Determine where to spawn the target along the Y axis
|
||||
Size winSize = Director::getInstance()->getVisibleSize();
|
||||
float minY = getOwner()->getContentSize().height/2;
|
||||
|
@ -52,7 +52,7 @@ void EnemyController::onEnter()
|
|||
_owner->runAction( Sequence::create(actionMove, actionMoveDone, nullptr) );
|
||||
}
|
||||
|
||||
void EnemyController::onExit()
|
||||
void EnemyController::onRemove()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ protected:
|
|||
|
||||
public:
|
||||
virtual bool init() override;
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
virtual void onAdd() override;
|
||||
virtual void onRemove() override;
|
||||
virtual void update(float delta) override;
|
||||
|
||||
static EnemyController* create(void);
|
||||
|
|
|
@ -20,13 +20,13 @@ bool PlayerController::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void PlayerController::onEnter()
|
||||
void PlayerController::onAdd()
|
||||
{
|
||||
ComController::onEnter();
|
||||
ComController::onAdd();
|
||||
setTouchEnabled(true);
|
||||
}
|
||||
|
||||
void PlayerController::onExit()
|
||||
void PlayerController::onRemove()
|
||||
{
|
||||
setTouchEnabled(false);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,8 @@ public:
|
|||
|
||||
public:
|
||||
virtual bool init() override;
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
virtual void onAdd() override;
|
||||
virtual void onRemove() override;
|
||||
virtual void update(float delta) override;
|
||||
|
||||
static PlayerController* create(void);
|
||||
|
|
|
@ -19,9 +19,9 @@ bool ProjectileController::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void ProjectileController::onEnter()
|
||||
void ProjectileController::onAdd()
|
||||
{
|
||||
ComController::onEnter();
|
||||
ComController::onAdd();
|
||||
auto winSize = Director::getInstance()->getVisibleSize();
|
||||
auto origin = Director::getInstance()->getVisibleOrigin();
|
||||
_owner->setPosition( Vec2(origin.x+20, origin.y+winSize.height/2) );
|
||||
|
@ -30,7 +30,7 @@ void ProjectileController::onEnter()
|
|||
static_cast<SceneController*>(com)->getProjectiles().pushBack(_owner);
|
||||
}
|
||||
|
||||
void ProjectileController::onExit()
|
||||
void ProjectileController::onRemove()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ protected:
|
|||
|
||||
public:
|
||||
virtual bool init() override;
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
virtual void onAdd() override;
|
||||
virtual void onRemove() override;
|
||||
virtual void update(float delta) override;
|
||||
|
||||
static ProjectileController* create(void);
|
||||
|
|
|
@ -24,16 +24,16 @@ bool SceneController::init()
|
|||
return true;
|
||||
}
|
||||
|
||||
void SceneController::onEnter()
|
||||
void SceneController::onAdd()
|
||||
{
|
||||
ComController::onEnter();
|
||||
ComController::onAdd();
|
||||
_fAddTargetTime = 1.0f;
|
||||
|
||||
static_cast<ComAudio*>(_owner->getComponent("Audio"))->playBackgroundMusic("background.wav", true);
|
||||
static_cast<ComAttribute*>(_owner->getComponent("CCComAttribute"))->setInt("KillCount", 0);
|
||||
}
|
||||
|
||||
void SceneController::onExit()
|
||||
void SceneController::onRemove()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@ protected:
|
|||
|
||||
public:
|
||||
virtual bool init() override;
|
||||
virtual void onEnter() override;
|
||||
virtual void onExit() override;
|
||||
virtual void onAdd() override;
|
||||
virtual void onRemove() override;
|
||||
virtual void update(float delta) override;
|
||||
|
||||
static SceneController* create();
|
||||
|
|
Loading…
Reference in New Issue