Skip to content

Instantly share code, notes, and snippets.

View yonekawa's full-sized avatar

Kenichi Yonekawa yonekawa

  • freee K.K.
  • Japan
View GitHub Profile
@yonekawa
yonekawa / gist:3356846
Created August 15, 2012 06:03
enchant.js issues?
window.onload = function() {
enchant();
var game = new Game(640, 960);
game.fps = 60;
game.preload('bg.jpg');
game.preload('chara1.png');
game.onload = function () {
var bg = new Sprite(640, 960);
bg.image = game.assets['bg.jpg'];
diff --git a/enchant.js b/enchant.js
index bf83ff1..0d0ed17 100644
--- a/enchant.js
+++ b/enchant.js
@@ -1809,7 +1809,8 @@ enchant.Sprite = enchant.Class.create(enchant.Entity, {
if (this._dirty) {
this._style[enchant.ENV.VENDOR_PREFIX + 'Transform'] = [
'rotate(', this._rotation, 'deg)',
- 'scale(', this._scaleX, ',', this._scaleY, ')'
+ 'scale(', this._scaleX, ',', this._scaleY, ')',
@yonekawa
yonekawa / CDVViewController.m.patch
Created October 3, 2012 01:08
Fix PhoneGap2.1-iOS does not work with RequireJS
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index a0a29f0..520050d 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -510,7 +510,7 @@
// The iOSVCAddr is used to identify the WebView instance when using one of the XHR js->native bridge modes.
// The .onNativeReady().fire() will work when cordova.js is already loaded.
// The _nativeReady = true; is used when this is run before cordova.js is loaded.
- NSString* nativeReady = [NSString stringWithFormat:@"cordova.iOSVCAddr='%lld';try{cordova.require('cordova/channel').onNativeReady.fire();}catch(e){window._nativeReady = true;}", (long long)self];
+ NSString* nativeReady = [NSString stringWithFormat:@"window.iOSVCAddr='%lld';try{cordova.require('cordova/channel').onNativeReady.fire();}catch(e){window._nativeReady = true;}", (long long)self];
@yonekawa
yonekawa / gist:3945014
Created October 24, 2012 09:14
Leak code
enchant();
var NewScene = enchant.Class.create(enchant.Scene, {
initialize: function() {
enchant.Scene.call(this);
for (var i = 0; i < 100; i++) {
var sprite = new Sprite(32, 32);
sprite.image = enchant.Game.instance.assets['chara1.png'];
this.addChild(sprite);
}
@yonekawa
yonekawa / CDVCommandDelegate.h.patch
Created November 28, 2012 07:37
Fix PhoneGap2.2-iOS does not work with RequireJS
diff --git a/cordova/ios/CordovaLib/Classes/CDVCommandDelegate.h b/cordova/ios/CordovaLib/Classes/CDVCommandDelegate.h
--- a/cordova/ios/CordovaLib/Classes/CDVCommandDelegate.h
+++ b/cordova/ios/CordovaLib/Classes/CDVCommandDelegate.h
@@ -42,6 +42,8 @@
// without reason. Without the run-loop delay, alerts used in JS callbacks may result
// in dead-lock. This method must be called from the UI thread.
- (void)evalJs:(NSString*)js scheduledOnRunLoop:(BOOL)scheduledOnRunLoop;
+// Patch for using RequireJS.
+- (void)evalJs:(NSString*)js scheduledOnRunLoop:(BOOL)scheduledOnRunLoop useNativeEvalAndFetch:(BOOL)useNativeEvalAndFetch;
// Runs the given block on a background thread using a shared thread-pool.

現象

HTML5版(Canvas)のLWFで、あるフレームを実行するとrootMovieがdestroyされる。 そのフレーム以降のアニメーションも同様。 iOS6のUIWebView, Chromeで確認。その他は未確認。

クライアントコード

以下を使ってmainを回してexec & renderしている。 https://github.com/yonekawa/lwf.enchant.js/blob/master/lwf.enchant.coffee

flaファイルの構成

<?xml version='1.0'?>
<signatures version='1.0'>
<enum name='kDynamicBodyType' value='2'/>
<enum name='kKinematicBodyType' value='1'/>
<enum name='kStaticBodyType' value='0'/>
<class name='B2DBody'>
<method selector='addFixureForShape:friction:restitution:density:isSensor:'>
<arg name='shape' index='0' declared_type='B2DShape*' type='@'/>
<arg name='friction' index='1' declared_type='id' type='@'/>
<arg name='restitution' index='2' declared_type='id' type='@'/>
@yonekawa
yonekawa / gist:57d44a440b798b25b32d
Created May 7, 2014 08:45
AttributionIdentifiers without facebook app
diff --git a/facebook/src/com/facebook/internal/AttributionIdentifiers.java b/facebook/src/com/facebook/internal/AttributionIdentifiers.java
index 1c8f630..f142f25 100644
--- a/facebook/src/com/facebook/internal/AttributionIdentifiers.java
+++ b/facebook/src/com/facebook/internal/AttributionIdentifiers.java
@@ -104,25 +104,23 @@ public class AttributionIdentifiers {
try {
String [] projection = {ATTRIBUTION_ID_COLUMN_NAME, ANDROID_ID_COLUMN_NAME, LIMIT_TRACKING_COLUMN_NAME};
Cursor c = context.getContentResolver().query(ATTRIBUTION_ID_CONTENT_URI, projection, null, null, null);
- if (c == null || !c.moveToFirst()) {
- return null;
import SwiftFlux
struct CounterActions {
struct Plus: Action {
typealias Payload = Int
let number: Int
func invoke(dispatcher: Dispatcher) {
dispatcher.dispatch(self, result: Result(value: number))
}
import APIKit
import SwiftFlux
struct TodoActions {
struct Fetch {
typealias Payload = Todo
func invoke(dispatcher: Dispatcher) {
Session.sendRequest(TodoFetch(id: 1)) { (result) in
switch response {
case .Success(let todo):