Forum Replies Created
-
AuthorPosts
-
I can copy and paste canvas.monkey – which is 1600 lines long – until the doc is longer than 200000 lines, at which point the textview knob disappears, which is a bug I’ll look at later.
But no crash. I am however use plain ted2, not ted2go. What are you using to rebuild? rebuildall or rebuildall2go?
Structs cannot use ‘extends’ – I’m sure they use to give an error, not sure what happened there but I’ll add the error back.
Hypothetical structs of common base type could not (easily) be added to a stack anyway, mainly because different derived structs may have different sizes, eg: a ‘Text Extends Drawable’ struct may have an extra ‘text’ field etc, and stacks (or really the underlying arrays) expect elements to be of the same size for sane indexing. This is not a problem with class objects, as elements are just pointers.
In general, this is the core problem with allowing structs to ‘extend’ other structs – converting a derived struct to a base struct (when assigning to var or passing to function) often means truncating the derived struct – and this really means changing the ‘virtual function table’ pointer in case derived’s virtual methods use fields not in base. This means virtual methods are pretty much useless.
All in all it gets pretty ugly so I decided to give it a miss.
Hi,
AssetsDir() is working OK here (see below) although you can’t depend on it being present on all targets (eg: there is no AssetsDir on android).
I’m happy to add more of these BlahDir()s though if people let me know what they want.
Monkey1234567891011121314#Import "<std>"Using std..Function Main()Print "AssetsDir="+AssetsDir()SaveString( "Hello World!",AssetsDir()+"test.txt" )Print LoadString( AssetsDir()+"test.txt" )EndYeah, canvas.CopyPixmap is about it right now. GLES2.0 lets you read backbuffer/write textures but not vice versa. It shouldn’t be too hard to ‘fake’ it though – please post an issue on github to remind me!
You may need to add something like:
#Import “mylib/include/*.h”
#Import “<mylib.h>”
…to your mylib.monkey2 module file. The first import adds the ‘include dir’ to the module, the second adds the actual header file for the lib.
Take a look at, say, modules/openal.monkey2 for how to import a ‘prebuilt’ lib.
Might be time for a new binary release soon…
…actually, this:
per_list.Sort(ComparePersons(x, y) )
looks a bit wrong. This actually calls the ‘ComparePersons’ function, but you probably wanted to pass the function to Sort() instead. The way to do that is simply:
per_list.Sort( ComparePersons )
Easy!
Since there is no ‘()’ after ComparePersons, the function is *not* actually called…
When you go:
per_list.Sort( ComparePersons(x,y) )
…this does actually call ComparePersons (which returns an int) and then passes the returned int as a parameter to Sort(), which is probably not what you meant.
Basically, ‘func()’ calls a function, while ‘func’ on its own does not. This takes a bit of getting used to but the main idea here is that it allows you to pass functions around just like they were ints or floats or arrays or strings or whatever!
Have a look at the source for LoadBump – it basically just uses Texture.Load,Texture.LoadNormal and Image.SetTexture.
Here’s the basic idea:
Monkey1234567891011121314151617181920212223#Import "<std>"Using std..Function Main()Local stack:=New Stack<Float>( 10 )For Local i:=0 Until stack.Lengthstack[i]=Rnd()Nextstack.Sort( Lambda:Int( x:Float,y:Float )Return x<=>yEnd )For Local t:=Eachin stackPrint tNextEndThe ‘lambda’ is an ‘inline’ funtion. You can also use a global function or method here, eg: stack.Sort( MyGlobalCompareFunc ).
The ‘<=>’ operator might look a bit weird, but it basically just returns an int value <0 if x<y, >0 if x>y and 0 if x=y. This is the default behavior if you just call Sort() with no comparison param.
I can post audio highlighting the issue if needed?
…that would be useful.
This is just how openal works – I am ‘faking’ panning by positioning the audio source, and it doesn’t work with stero (kinda understandably).
I may be able to ‘fake’ stero panning somehow in the future, but it’s very low priority.
I don’t know when in-app purchases will be done. 6 months *sounds* reasonable but I’m up to my neck in 3d stuff right now and am not making any promises. IMO, stick with monkey1 if you want something with IAP for now.
Nice!
Do you think Reflection will ever allow generics?
Not sure yet, possibly, but it’ll never be able to ‘instantiate’ types that haven’t already been instantiated at compile time, so it’ll be more limited. eg: You wont be able to use Stack<Vec> if there isn’t a ‘compiled in’ one to begin with. But this is probably OK for many uses.
Not yet, you still have to do this manually.
I want to support it though.
Ok, haven’t actually tried it but I think the problem is here:
Local d:= newObj.GetDecl( key )
In the case of objects, ‘key’ will contain a ‘:’ char so GetDecl will be returning an ‘invalid’ decl as fields don’t have ‘:’ in their names.
This isn’t easy to spot, as the debugger is struggling a bit with ‘internal’ types like Decl, Variant etc!
A better approach may be to use a ‘class’ key in the json and leave field names ‘unmangled’.
-
AuthorPosts