I found that messing around with _ccbScriptCache got some useful results, such as triggering the keyboard and mouse events of the current behavior.
These only work if the behavior has its onKeyEvent or onMouseEvent prototype functions defined. Also, this wont cause key/mouse events globally (wont cause the events on other scripts/the game itself), it will only cause the event within the behavior its in.
// A method that triggers a key event to happen, despite the user never triggering it themselves ccbTriggerKeyEvent = function(keycode, pressed, scriptIndex) { // parameters: // keycode, pressed, [scriptIndex] // keycode = The keycode to trigger. Refer to the standard documents of the JavaScript language // for a list of each key code and what keyboard key each code refers to. // pressed = Wether to set if the specified key is being pressed down or was pressed but left // up. Possible values: 0 = down, 1 = up. // scriptIndex [optional] = The index of the current running script. Should only be 0 unless // this function fails somehow. // Optional parameter handler var scriptIndex = ((arguments.length == 2) || (scriptIndex == null) || (typeof scriptIndex === "undefined") || (typeof scriptIndex !== "number")) ? 0 : scriptIndex; _ccbScriptCache[scriptIndex]['onKeyEvent'](keycode, pressed); };
// A method that triggers a mouse event to happen, despite the user never triggering it themselves ccbTriggerMouseEvent = function(mouseEvtId, wheelDelta, scriptIndex) { // parameters: // mouseEvtId, wheelDelta, [scriptIndex] // mouseEvtId = The mouse event to trigger. Possible values: 0 = move moved, 1 = mouse clicked, // 2 = left mouse up, 3 = left mouse down, 4 = right mouse up, 5 = right mouse down. // wheelDelta = The speed of the mouse wheel, if the mouse wheel event id is passed. Negative // value is mouse wheel backwards, positive value is mouse wheel fowards. // scriptIndex [optional] = The index of the current running script. Should only be 0 unless // this function fails somehow. // Optional parameter handler var scriptIndex = ((arguments.length == 2) || (scriptIndex == null) || (typeof scriptIndex === "undefined") || (typeof scriptIndex !== "number")) ? 0 : scriptIndex; _ccbScriptCache[scriptIndex]['onMouseEvent'](mouseEvtId, wheelDelta); };
|