Unknown identifier
Monkey Forums/Monkey Programming/Unknown identifier
| ||
Hello, monkey newbie here. I'm trying to convert some blitzmax code to monkey but I get unknown identifier errors all over the place. It seems variables declared as Globals throw errors when I refer to them inside functions that reside in external imported source files. Any ideas how to tackle this? For example: ---- main.monkey -------- Import entity Global Ship:TEntity Class Game2 Extends App Method OnCreate () Init_Entity(Ship, 50, 50) ---- entity.monkey ------ Class TEntity blahblah End Function Init_Entity(P:TEntity, PosX:Int, PosY:Int) If P = Ship ' This throws an error |
| ||
I think your problem is that you are not importing "main" into "entity": main.monkey: entity.monkey: |
| ||
That worked. Thanks :) The program compiles now but there's a new problem: the browser returns a null object access error for my Loadimage("ship.png"). I'm pretty sure the paths are ok, I threw the png file into every possible sub-folder of my project folder, heh. Hmmm... |
| ||
Guessing somewhat, but do you need to do... Ship = New TEntity()? |
| ||
Files are case-sensitive and they need to be in a folder called yourproject.data - so in your example: main.data |
| ||
Guessing somewhat, but do you need to do... Ship = New TEntity()? Wow, I completely forgot. Now it works, thanks :D |
| ||
Is there a performance hit to speak of for GrabImage? I've been using DrawSubImageRect a lot in blitzmax for sprite sheet drawing, but monkey doesn't seem to have this function so I'll have to resort to GrabImage and SetHandle instead. I'll probably be grabbing images at 30-40 times per loop (at most). |
| ||
If you like DrawSubImageRect, use DrawImageRect in Monkey: Function DrawImageRect( image:Image, x#, y#, srcX, srcY, srcWidth, srcHeight, frame=0 ) Function DrawImageRect( image:Image, x#, y#, srcX, srcY, srcWidth, srcHeight, rotation#, scaleX#, scaleY#, frame=0 ) |
| ||
i use DrawImageRect( image:Image, x#, y#, srcX, srcY, srcWidth, srcHeight, frame=0 ) and havent noticed any kind of performance hit.if anything its slightly faster. |
| ||
The thing missing from DrawImageRect as far as I can tell is the option to set handle offsets, so GrabImage and SetHandle look more appealing at the moment, at least for sprites. |
| ||
grabimage only needs to be used to generate new images, then you just draw them as you would any other images. |