Hi, I just used a little transformation in a new game (pic [1], demo later) and wrote this which looks rubish and not so ruby-sh: transform = NSAffineTransform.transform transform.translateXBy 20, yBy: 20 # looks ugly transform.concat The MacRuby examples are all like this, and #translate doesn't exist, but I wonder if I missed something there? ciao, tom [1] https://skitch.com/tomk32/rahp3/sirtet
Code works for me, so it's not really clear to me which #transform method you are missing. Regarding the style, I prefer to use parenthesis, which makes it a bit clearer. If you really dislike it and have to use it many times, you could of course wrap it: $ macirb irb(main):001:0> class NSAffineTransform irb(main):002:1> def translate(x, y) irb(main):003:2> translateXBy(x, yBy:y) irb(main):004:1> end irb(main):005:0> end => nil irb(main):006:0> transform = NSAffineTransform.transform => #<NSAffineTransform:0x20022c040> irb(main):007:0> transform.translate(20, 20) => #<NSAffineTransform:0x20022c040> Laurent: Coincidentally, I tried to alias translateXBy:yBy: to translate, but when calling it it gives this error: irb(main):013:0> transform.translate(20, 20) ArgumentError: wrong number of arguments (2 for 2) On Fri, Apr 1, 2011 at 1:29 PM, Thomas R. Koll <info@ananasblau.com> wrote:
Hi,
I just used a little transformation in a new game (pic [1], demo later) and wrote this which looks rubish and not so ruby-sh:
transform = NSAffineTransform.transform transform.translateXBy 20, yBy: 20 # looks ugly transform.concat
The MacRuby examples are all like this, and #translate doesn't exist, but I wonder if I missed something there?
ciao, tom
[1] https://skitch.com/tomk32/rahp3/sirtet
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Am 01.04.2011 um 14:54 schrieb Eloy Duran:
Code works for me, so it's not really clear to me which #transform method you are missing. Regarding the style, I prefer to use parenthesis, which makes it a bit clearer.
I didn't mean functionality, just the style which looks more like objC than ruby.
Oh my bad, I thought you said the #trandform method didn't exist, but you said #translate. Anyways, regarding the syntax, I personally have no problem with it, I used to long ago, but it grew on me. The thing is, this isn't easily fixable without adding layers that map methods (like HotCocoa), nor do I think we shouyld hide it from the user, because all API docs use the objc style selectors, so hiding this from the user would make it even harder to translate objc code to MacRuby. On Fri, Apr 1, 2011 at 2:57 PM, Thomas R. Koll <info@ananasblau.com> wrote:
Am 01.04.2011 um 14:54 schrieb Eloy Duran:
Code works for me, so it's not really clear to me which #transform method you are missing. Regarding the style, I prefer to use parenthesis, which makes it a bit clearer.
I didn't mean functionality, just the style which looks more like objC than ruby.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (2)
-
Eloy Duran
-
Thomas R. Koll