[MonoTouch] A monotouch wrapper for the Sparrow 2D library

Duane Wandless duane at wandless.net
Mon Feb 21 11:16:50 EST 2011


I have updated so the demo works with the AddEventListner.

Thanks for letting me know it wasn't working.
Duane

On Mon, Feb 21, 2011 at 10:41 AM, fmuaddib <fmuaddib at gmail.com> wrote:

> Thank you, that is fixed now! It must be a monodevelop limitation (all
> the "using" statements in the other partial classes should be
> automatically parsed and included before compilation to avoid such
> errors IMHO).
>
> But I still got four errors:
>
> Game.cs(37,37): Error CS1502: The best overloaded method match for
> `Sparrow.SPEventDispatcher.AddEventListener(Sparrow.EventDispatch,
> string, bool)' has some invalid arguments (CS1502) (SparrowTest)
> Game.cs(37,37): Error CS1503: Argument `#1' cannot convert
> `MonoTouch.ObjCRuntime.Selector' expression to type
> `Sparrow.EventDispatch' (CS1503) (SparrowTest)
> Game.cs(45,45): Error CS1502: The best overloaded method match for
> `Sparrow.SPEventDispatcher.AddEventListener(Sparrow.EventDispatch,
> string, bool)' has some invalid arguments (CS1502) (SparrowTest)
> Game.cs(45,45): Error CS1503: Argument `#1' cannot convert
> `MonoTouch.ObjCRuntime.Selector' expression to type
> `Sparrow.EventDispatch' (CS1503) (SparrowTest)
>
> Maybe those are related to your new event listener method. Let me
> know, I'm eager to compile. :)
>
> Emanuele
>
> 2011/2/18 Duane Wandless <duane at wandless.net>:
> > That is a limitation with MonoDevelop.  Whenever MD auto generates the
> > MainWindowIPhone.xib.designer.cs file you have to add a using Sparrow to
> > that file.  There might be away to modify the XIB so MD will generate the
> > using clause.  But I haven't tried.  The XIB doesn't change that often.
> > So do a build, get the error, add the using clause, build again.
>  Slightly
> > annoying but you don't have to do it very often.
> > I forgot to put that in the README file.
> > Duane
> >
> > On Fri, Feb 18, 2011 at 5:48 AM, fmuaddib <fmuaddib at gmail.com> wrote:
> >>
> >> This is the error I got (twice) compiling the Sparrow wrapper:
> >> MainWindowIPhone.xib.designer.cs(25,25): Error CS0246: The type or
> >> namespace name `SPView' could not be found. Are you missing a using
> >> directive or an assembly reference? (CS0246) (SparrowTest)
> >>
> >> 2011/2/18 fmuaddib <fmuaddib at gmail.com>:
> >> > I have some problems with the dependencies. Can you put the projects
> >> > in a Mondevelop Solution (.sln)?
> >> >
> >> > 2011/2/17 Duane Wandless <duane at wandless.net>:
> >> >> Emanuele, I did modify AddEventListner to be more .NET like.
> >> >>
> >> >> To add an event listner:
> >> >> image.AddEventListener (doTouch, SPEvents.Touch);
> >> >> To remove:
> >> >> image.RemoveEventListner (doTouch, SPEvents.Touch);
> >> >> ---
> >> >> void doTouch (SPEvent e)
> >> >> {
> >> >>
> >> >> Works very nicely.  Have you tried using the bindings?
> >> >> Duane
> >> >> On Thu, Feb 17, 2011 at 1:14 PM, fmuaddib <fmuaddib at gmail.com>
> wrote:
> >> >>>
> >> >>> Great idea, maybe it could be even more simplified thank the obj-c
> >> >>> version thanks to c# predicates. I think that the monotouch platform
> >> >>> is the best for something fast and efficient like sparrow. Managing
> >> >>> iOS graphics in monotouch can be much simplier than in obj-c, like
> the
> >> >>> Monotouch.Dialog wrapper did for the cocoa interfaces without having
> >> >>> to write dozens of delegates and controllers!!
> >> >>>
> >> >>> If you need an hand let me know.
> >> >>> Emanuele
> >> >>>
> >> >>> 2011/2/6 Miguel de Icaza <miguel at novell.com>:
> >> >>> > Hello,
> >> >>> >
> >> >>> >> I started the bindings for Sparrow.  It looks like a good API.
>  The
> >> >>> >> MonoTouch project is the beginnings of the Demo app which works
> >> >>> >> nicely.
> >> >>> >> https://github.com/trustme/Sparrow
> >> >>> >
> >> >>> > This looks nice!
> >> >>> >
> >> >>> > May I suggest that in SPEventDispatcher you flag the
> >> >>> > AddEventListener
> >> >>> > as internal, and expose a method that takes a delegate instead?
> >> >>> >
> >> >>> > That way users do not have to know about selectors, instances and
> >> >>> > flagging things with [Export], they would do:
> >> >>> >
> >> >>> > AddEventListener (OnBoundaryChange, "boundaryChange", true);
> >> >>> >
> >> >>> > The implementation looks like this:
> >> >>> >
> >> >>> > object AddEventListener (NSAction action, string evenType, bool
> >> >>> > retain)
> >> >>> > {
> >> >>> >    var dispatcher = new Dispatcher (action);
> >> >>> >    RealAddEventListener (Dispatcher.InvokeSelector, dispatcher,
> >> >>> > eventType, retain);
> >> >>> >    return dispatcher;
> >> >>> > }
> >> >>> >
> >> >>> > [Register ("__SparrowClassDispatcher")]
> >> >>> > class Dispatcher : NSObject {
> >> >>> >    public static Selector InvokeSelector = new Selector
> ("invoke");
> >> >>> >    NSAction action;
> >> >>> >    [Export ("invoke")]
> >> >>> >    public Dispatcher (NSAction action) { this.action = action; }
> >> >>> >
> >> >>> >    [Export ("apply")]
> >> >>> >    [Preserve (Conditional = true)]
> >> >>> >    public void Apply () { action (); }
> >> >>> > }
> >> >>> >
> >> >>
> >> >>
> >> >
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monotouch/attachments/20110221/65a657d3/attachment-0001.html 


More information about the MonoTouch mailing list