From 88186cf6787d7235d81f4440d39709b6d780a83d Mon Sep 17 00:00:00 2001 From: Alexandr Korsak Date: Sun, 1 Jul 2018 17:07:01 +0300 Subject: [PATCH 1/3] use proper way for regex pattern, it would work fine in pattern on java compilation --- Sources/gecko/Assets.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/gecko/Assets.hx b/Sources/gecko/Assets.hx index 3a5913a..7ae8906 100755 --- a/Sources/gecko/Assets.hx +++ b/Sources/gecko/Assets.hx @@ -30,7 +30,7 @@ class Assets { static private function _parseAssetName(name:String, ext:Bool = false) : String { name = ext ? name : Path.withoutExtension(name); name = Std.parseInt(name.charAt(0)) != null ? "_" + name : name; - return (~/[\/\.-\s]/gi).replace(Path.normalize(name), "_"); + return new EReg("[\\/\\.\\-\\s]", "gi").replace(Path.normalize(name), "_"); } static inline private function _existsAssetsName(name:String, type:String) : Bool { From 80296fe5817c6d2f1eb4fe2cb9da78b759b8e23b Mon Sep 17 00:00:00 2001 From: Alexandr Korsak Date: Sun, 1 Jul 2018 17:20:52 +0300 Subject: [PATCH 2/3] compiled issue Vector2g for java project --- Sources/gecko/Transform.hx | 10 ++++----- Sources/gecko/math/Vector2g.hx | 40 +++++++++++++++++----------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Sources/gecko/Transform.hx b/Sources/gecko/Transform.hx index 81f3998..214a02a 100755 --- a/Sources/gecko/Transform.hx +++ b/Sources/gecko/Transform.hx @@ -71,8 +71,8 @@ class Transform { public var size(get, null):Point; private var _size:Point; - public var flip(get, null):Vector2g; - private var _flip:Vector2g; + public var flip(get, null):Vector2g; + private var _flip:Vector2g; public var rotation(get, set):Float; private var _rotation:Float = 0; @@ -372,7 +372,7 @@ class Transform { _dirtyPosition = false; } - private function _vecDirty(vec:Vector2g) { + private function _vecDirty(vec:Vector2g) { _setDirty(true); _dirtyPosition = false; } @@ -546,7 +546,7 @@ class Transform { return _pivot; } - function get_flip():Vector2g { + function get_flip():Vector2g { if(_dirty)updateTransform(); return _flip; } @@ -718,4 +718,4 @@ private typedef SkewCache = { var sinX:Float; var cosY:Float; var sinY:Float; -}; \ No newline at end of file +}; diff --git a/Sources/gecko/math/Vector2g.hx b/Sources/gecko/math/Vector2g.hx index 79f1bf4..4c6a5fb 100755 --- a/Sources/gecko/math/Vector2g.hx +++ b/Sources/gecko/math/Vector2g.hx @@ -1,19 +1,19 @@ package gecko.math; -class Vector2g { //todo add observer - public var x(get, set):T; - private var _x:T; - public var y(get, set):T; - private var _y:T; +class Vector2g { //todo add observer + public var x(get, set):Bool; + private var _x:Bool; + public var y(get, set):Bool; + private var _y:Bool; - private var _observer:Vector2g -> Void; + private var _observer:Vector2g -> Void; public var isObserved(default, null):Bool; - inline public function new(x:T, y:T) { + inline public function new(x:Bool, y:Bool) { set(x, y); } - public function setObserver(cb:Vector2g -> Void) : Void { + public function setObserver(cb:Vector2g -> Void) : Void { isObserved = true; _observer = cb; } @@ -22,7 +22,7 @@ class Vector2g { //todo add observer isObserved = false; } - public inline function set(x:T, y:T) { + public inline function set(x:Bool, y:Bool) { if(x != _x || y != _y){ _setX(x); _setY(y); @@ -30,49 +30,49 @@ class Vector2g { //todo add observer } } - inline private function _setX(x:T) { + inline private function _setX(x:Bool) { _x = x; } - inline private function _setY(y:T) { + inline private function _setY(y:Bool) { _y = y; } - public inline function clone(vec:Vector2g) : Vector2g { - return new Vector2g(x, y); + public inline function clone(vec:Vector2g) : Vector2g { + return new Vector2g(x, y); } - public inline function copy(vec:Vector2g) : Void { + public inline function copy(vec:Vector2g) : Void { set(vec.x, vec.y); } - public inline function isEqual(vec:Vector2g) : Bool { + public inline function isEqual(vec:Vector2g) : Bool { return (x == vec.x && y == vec.y); } - inline function get_x():T { + inline function get_x():Bool { return _x; } - function set_x(value:T):T { + function set_x(value:Bool):Bool { if(value == _x)return _x; _x = value; if(isObserved)_observer(this); return value; } - inline function set_y(value:T):T { + inline function set_y(value:Bool):Bool { if(value == _y)return _y; _y = value; if(isObserved)_observer(this); return value; } - inline function get_y():T { + inline function get_y():Bool { return _y; } inline public function toString() : String { return 'Vector2g($_x, $_y)'; } -} \ No newline at end of file +} From 0331be855f8d728e21c40d2ed694f12caef1f1a4 Mon Sep 17 00:00:00 2001 From: Alexandr Korsak Date: Mon, 2 Jul 2018 11:35:26 +0300 Subject: [PATCH 3/3] Remove getPool method because of the issues on inherit the static methods in Java implementation --- Sources/gecko/macros/PoolBuilder.hx | 3 +-- docs/guide/README.md | 14 +++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Sources/gecko/macros/PoolBuilder.hx b/Sources/gecko/macros/PoolBuilder.hx index df76878..060ac93 100755 --- a/Sources/gecko/macros/PoolBuilder.hx +++ b/Sources/gecko/macros/PoolBuilder.hx @@ -39,7 +39,6 @@ class PoolBuilder { //todo add a instancePoolId (unique id) to debug? var poolFields = (macro class { static var __pool__ = new gecko.utils.Pool($p{path}, {amount: $v{amount}/*, args: $v{arguments}*/}); - static inline public function getPool() return __pool__; }).fields; //add create function @@ -321,4 +320,4 @@ class PoolBuilder { default: false; } } -} \ No newline at end of file +} diff --git a/docs/guide/README.md b/docs/guide/README.md index 13595e5..1001277 100644 --- a/docs/guide/README.md +++ b/docs/guide/README.md @@ -1,13 +1,13 @@ # Base Object -This framework use object pooling to avoid garbage collector issues. Some objects, like scenes, entites, componentes, or systems (among other objects) inherit from `gecko.BaseObject`, which is a special object without functionality defined, but allow us to recycle our instances. +This framework use object pooling to avoid garbage collector issues. Some objects, like scenes, entites, componentes, or systems (among other objects) inherit from `gecko.BaseObject`, which is a special object without functionality defined, but allow us to recycle our instances. Every object inherited from `gecko.BaseObject` must be instantiated via the static method `MyObject.create()`, this will check his pool to get and reuse an old instance, or if no one exists create it. When you're done with your object, just destroy it with the instance method `myObject.destroy()` and it will be returned to his pool. To manage how your objects are created or destroyed you can use two instance methods, `init` and `beforeDestroy`. - __init__: this method is executed always when you use `MyObject.create()`. You can add some parameters to it, and this params will be passed to the __create__ method. -- __beforeDestroy__: this method is executed before your object is destroyed, use it to clean it or do whatever you need before recycle it. This methods needs to be override because is inherited from __BaseObject__. +- __beforeDestroy__: this method is executed before your object is destroyed, use it to clean it or do whatever you need before recycle it. This methods needs to be override because is inherited from __BaseObject__. -For example: +For example: ```haxe class MyObject extends gecko.BaseObject { var name:String = ""; @@ -21,15 +21,15 @@ class MyObject extends gecko.BaseObject { trace("i will be destroyed!!!!"); } } -``` +``` ```haxe var myObject = MyObject.create("Jonh Doe"); //print "Jonh Doe" //do something with your object and when you're done just destroy it -myObject.destroy(); +myObject.destroy(); ``` -Keep in mind that is possible `beforeDestroy` may not be executed when you use `myObject.destroy()`. If the game loop o the rendering loop is running the destruction of your object will be delayed to the end of the frame. If you need to know the state of your object use `myObject.isAlreadyDestroyed` which is a boolean value. +Keep in mind that is possible `beforeDestroy` may not be executed when you use `myObject.destroy()`. If the game loop o the rendering loop is running the destruction of your object will be delayed to the end of the frame. If you need to know the state of your object use `myObject.isAlreadyDestroyed` which is a boolean value. -In some (unsual) cases maybe you want acces to your object's pool to check their length, clear, debug, or whatever, just use `MyObject.getPool()`. \ No newline at end of file +In some (unsual) cases maybe you want acces to your object's pool to check their length, clear, debug, or whatever, just use `MyObject.__pool__`.