Forum Replies Created
-
AuthorPosts
-
set the random seed to a value derived from the time
I ended up with a modest $2 a month, as I found some wiggle room, but yeah if I ever get around to publishing something with it and it actually sells, a decent donation has to be in order!
it would be easier to test with this #Import “vec2d.monkey2”
jplib?
can you reduce it to a minimal example that can be run on the defaul modules ?
the more complex version! you can replicate what happens to eachin loop
Monkey12345678910111213141516171819202122232425262728293031323334353637383940414243#Import "<std>"Using std..Class myItemsField ID:IntField content:StringMethod New(i:Int,s:String)ID=icontent=sEndEndFunction Main()Local alist:List<myItems> = New List<myItems>alist.Add(New myItems(1,"One"))alist.Add(New myItems(2,"Two"))alist.Add(New myItems(3,"Three"))alist.Add(New myItems(4,"Four"))alist.Add(New myItems(5,"Five"))alist.Add(New myItems(6,"Six"))alist.Add(New myItems(7,"Seven"))alist.Add(New myItems(8,"Eight"))alist.Add(New myItems(9,"Nine"))alist.Add(New myItems(10,"Ten"))Local iterator:=alist.All()While Not iterator.AtEndWhile iterator.Current.ID < 4iterator.Bump()WendLocal value:=iterator.CurrentIf value.ID > 7 ContinuePrint value.ID+ " " + value.contentiterator.Bump()WendEndIf you wanted you could implement a custom iterator too, but in the real world… just do what Jesse suggested…
Monkey1RectangleMX::RectangleMX():Rectangle(0,0)got it!
but what I don’t quite follow, if this never gets executed (and it doesn’t) why is it needed ?
Monkey1234567891011121314151617Externclass RectMX="RectangleMX"Method area:Float()="Area" ' order unimportantfield height:Float="Height"Method New( w:float,h:float )Field width:Float="Width"EndPublicClass exRectMX Extends RectMXmethod New(w:Float, h:Float)Super.New(w,h)EndEndwon’t compile for example
I’m not sure what you mean, as Super.New(.. also doesn’t compile
I can’t see any way to extend an extern class at all
trouble using extern classes with any kind of extention
using either extends or extention I get Error : Super class ‘default.Rect’ has no default constructor
there is a slight complication in that the only a (float,float) constructor, but it will say the same if there is a () constructor…Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445Namespace myapp#Import "<std>"#Import "<mojo>"Using std..Using mojo..Class MyWindow Extends WindowField zoom:=.01Field radius:=400.2Field x:=9.3Field y:=9.2Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=Null )Super.New( title,width,height,flags )EndMethod OnRender( canvas:Canvas ) OverrideApp.RequestRender()canvas.DrawText("Press space to zoom, Enter to grow circle, R to reset",10,10)canvas.Scale(zoom,zoom)canvas.DrawCircle( x,y,radius )canvas.Color=Color.Blackcanvas.DrawLine(x,y,x+Cos(0.7)*radius,y+Sin(0.7)*radius)If Keyboard.KeyDown(Key.Space) Then zoom=zoom*1.1If Keyboard.KeyDown(Key.Enter) Then radius=radius*1.1If Keyboard.KeyDown(Key.R)zoom=.01radius=400.2EndifPrint zoomEndEndFunction Main()New AppInstanceNew MyWindowApp.Run()Endhows that
there might be a rounding error involved ?
gah just when I thought I had it all,
if I try to extend MXRectangle (in MX2 code) (so I can add extra code to some of the methods) its asking for the default constructor of MXRectangle ?
I have callbacks (from C++ to MX2) working but then that would mean ctor / del callbacks and a callback for any method I wanted to intercept – doable but cumbersom
for example if I want each instance to keep a list of children to protect them from the GC (while the parent is still alive) ….
JNI (in Java) , Lua etc have a bunch of C routines to create language objects another way round would be if I could create a List<T> in C code without having to cope with all the MX2 name massaging (its not quite as bad as mangling!) but then that would probably be a bunch of work for something maybe not many people would use ??
lol just as well i’m having dns issues….
I’ll correct it, thanks
websites off line for a bit – sleeeeeeep (please
)
new changes really made things a lot easier, now a proper 1st class citizen, with c++ methods called from the mx2 class wonderful!
I’m tidying the code and just writing it all up now, I’ll post the link before long…
November 18, 2016 at 9:52 pm in reply to: how to get an extern class that extends bbObject and not void? #5223yeah, gotcha, cheers Mark
oh gods but the horror show…..
check your email….
ding ding ding, we have a winner, thanks Mark
I wasn’t actually thinking of bullet (as anyhow you promised it soon ;-p – still tempted to throw a very limited temporary thing together mind…)
Very good point about factory methods but you could always call the factory place the pointer in a field of a GC’d class that you *then* return from the wrapper… :-/ !
I’m thinking about putting together a blog post about wrapping for MX2 and including this idea as well, you wouldn’t happen to have any other wrapping secret sauce, that you think would be good to go in such a blog post would you?
-
AuthorPosts