Skip to content

Instantly share code, notes, and snippets.

@stevetranby
stevetranby / ion-bitwise.sublime-syntax
Last active April 27, 2018 17:38
WIP Syntax for the 'Ion' Language (from Bitwise Project) for Sublime Text 3
%YAML 1.2
---
# References:
# http://www.sublimetext.com/docs/3/syntax.html
# https://www.sublimetext.com/docs/3/settings.html
# https://www.sublimetext.com/docs/3/scope_naming.html
# https://github.com/shogas/vim-ion/blob/master/syntax/ion.vim
# https://github.com/odin-lang/sublime-odin/blob/master/Odin.sublime-syntax
#
# TODO: look at the following for improvements/enhancements
@stevetranby
stevetranby / STAnimateInSync.cpp
Last active May 13, 2016 07:55
Animate multiple Sprite Nodes each with a separate Animation
#include "extensions/STActions.h"
USING_NS_CC;
////////////////////////////////////////////////////////////////////////
STAnimateInSync::STAnimateInSync() {}
STAnimateInSync::~STAnimateInSync() {
// TODO: release all animtargets
}
@stevetranby
stevetranby / README.md
Last active September 20, 2021 03:55
Converting the laser beam example on ShaderToy to cocos2d-x shaders.

Laser beam example from Shader Toy https://www.shadertoy.com/view/XtBXW3

Usage: laserbeam.cpp - put this code inside the init method of a new project within HelloWorld.cpp. laserbeam.vert - put this in PROJECT_ROOT/Resources/res/ laserbeam.frag - put this in PROJECT_ROOT/Resources/res/

///////////////////////////////////////////////////////////////
// MARK: Colors -
Color3B STUtil::c3BFromHex(unsigned int hex)
{
GLubyte r = (hex >> 16) & 0xFF;
GLubyte g = (hex >> 8) & 0xFF;
GLubyte b = (hex ) & 0xFF;
return Color3B(r,g,b);
@stevetranby
stevetranby / STTextField.cpp
Last active November 27, 2017 01:49
Adding cursor support to ui::TextField
//
// STTextField.cpp
// scgamex
//
// Created by Steve Tranby on 7/11/15.
//
//
#include "stdafx.h"
@stevetranby
stevetranby / gist:b37ad3f913ed30cecf08
Last active August 29, 2015 14:13
This is the relevant code for creating a menu from code within a cocos2d-x 3.x project. Here I call to create the menu at launch in AppDelegate. The STDevice platform implementation utility class is used similar to how other platform-specific code is written in the core engine.
//////////////////////////////////////////////////////////
// STDevice.h
class STDevice {
public:
// implementation of getInstance() is left to platform impl file
static STDevice* getInstance();
};
//////////////////////////////////////////////////////////
// AppDelegate.cpp
@stevetranby
stevetranby / CCFileUtils.cpp
Last active October 25, 2019 17:58
A collection of files modified to support .obb extension files. Hopefully this is everything. The changes were as follows.
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@stevetranby
stevetranby / objc2all.sh
Created April 25, 2012 12:04
Converting Obj-c to CPP code
#!/usr/bin/env sh
# WARNING:
# WARNING: This script may destroy your code, make sure to backup before running.
# WARNING:
################################
# convert .m files to .cpp
################################
#ls -1 *.m | while read f
@stevetranby
stevetranby / snippet.cpp
Created March 29, 2012 05:49
call lua functions from c++ using with Cocos2dx
CCLOG("running scripts");
//test2p
lua_State *L = pEngine->getLuaState();
lua_getglobal(L, "test");
lua_call(L, 0, 0);
lua_getglobal(L, "test1r");
lua_call(L, 0, 1);
int ret = lua_tointeger(L, -1);
@stevetranby
stevetranby / gist:648075
Last active May 18, 2019 18:04
Quick if exists update else insert MSSQL
IF EXISTS (SELECT NULL FROM Users WHERE Email=@Email)
UPDATE Users SET Name=@Name WHERE Email=@Email
ELSE
INSERT INTO Users(Email, Name) VALUES (@Email, @Name)