Skip to content

Instantly share code, notes, and snippets.

// create a CastMessageBus to handle messages for a custom namespace
window.messageBus =
window.castReceiverManager.getCastMessageBus(
'urn:x-cast:com.hsienwei.test2048');
// handler for the CastMessageBus message event
window.messageBus.onMessage = function(event) {
console.log('Message [' + event.senderId + ']: ' + event.data);
if ( event.data == "continue") {
// init chromecast receiver
cast.receiver.logger.setLevelValue(0);
window.castReceiverManager = cast.receiver.CastReceiverManager.getInstance();
console.log('Starting Receiver Manager');
// handler for the 'ready' event
castReceiverManager.onReady = function(event) {
console.log('Received Ready event: ' + JSON.stringify(event.data));
window.castReceiverManager.setApplicationState("Application status is ready...");
};
HTMLActuator.prototype.message = function (won) {
var type = won ? "game-won" : "game-over";
var message = won ? "You win!" : "Game over!";
this.messageContainer.classList.add(type);
this.messageContainer.getElementsByTagName("p")[0].textContent = message;
window.messageBus.send(window.senderId, won ? "win" : "lose");
};
HTMLActuator.prototype.clearMessage = function () {
@hsienwei
hsienwei / unity.sublime-project
Created June 26, 2014 18:58 — forked from anonymous/unity.sublime-project
Sublime project file (Mac with Unity 4.x)
{
"folders":
[
{
"path": "your_project_path",
"file_exclude_patterns":
[
"*.dll",
"*.meta"
]
@hsienwei
hsienwei / gist:82778844500073133a82
Created July 30, 2014 09:22
一個簡單的測試用Log方法 用於objective-c
#ifdef DEBUG
# define debugLog(format, ...) NSLog(@"<Debug>: " format @" [" __FILE__ @":%i]", ##__VA_ARGS__, __LINE__)
#else
# define debugLog(format, ...)
#endif
@hsienwei
hsienwei / main.cpp
Created February 23, 2015 02:46
main.cpp in cocos2d-x + wxWidget
#include "main.h"
#include "AppDelegate.h"
#include "HelloWorldScene.h"
#include "cocos2d.h"
#include "wx/wx.h"
USING_NS_CC;
class MyApp : public wxApp
{
public:
clock_t t1, t2;
t1 = clock();
DoSomething();
t2 = clock();
float diff = ((float)(t2 - t1) / 1000000.0F) * 1000;
printf("battle total time : %f \n ", diff);
/*class TableDelegate
{
public:
int GetItemCount(){return 0;}
bool OnItemShow( Node *Item, int Index){};
};*/
template<class TableDelegateT>
class TableViewUtilEx
@hsienwei
hsienwei / 1.cpp
Created February 8, 2018 06:53
第一種作法, c++指標到c#從IntPtr轉換成byte後再依照自己的指定順序塞進結構中
PLUGIN_DLL_API const void* GetDataPtr(const int data_id, int &length)
{
length = sizeof(Data);
const Data* Dta = ... // 資料來源
if (NULL == Dta)
{
return NULL;
}
@hsienwei
hsienwei / 2.cpp
Created February 8, 2018 07:00
第二種作法, 將結構傳入c++中memcpy填值, 該作法Data在c#中一定要是struct不能為class
PLUGIN_DLL_API bool GetDataRef(const int data_id,
Data* ref)
{
const go3::BuildDataPN* report = go3::BuildDataTable3::Instance().GetTableData(data_id);
if (NULL == report)
{
return NULL;
}