Hi
during some test i notice that if you have create sprites BEFORE open a screem or windwoed screen, screen does not open at all
all sprite initializations must take place AFTER openscreen and then they work
if this is the case i believe it should be noted clearer in doc's
Sprite generation MUST be after openscreen ?
Re: Sprite generation MUST be after openscreen ?
Code or it didn't happen.
Re: Sprite generation MUST be after openscreen ?
if you mean about sample code, does it happens otherwise to ANYONE else ?!
anyway here is the sample from docs from "openwindowsscreen"
just change opnenwindowedscreen to the other commented area
anyway here is the sample from docs from "openwindowsscreen"
just change opnenwindowedscreen to the other commented area
Code: Select all
OpenWindow(0, 20, 20, 840, 640, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
; OpenWindowedScreen(WindowID(0), 20, 20, 800, 600)
Procedure RenderFrame()
Static x, y
ClearScreen(RGB(0, 0, 0))
x+1
DisplaySprite(0, x, 30)
FlipBuffers() ; continue the rendering
EndProcedure
; Register the render event so FlipBuffers() will trigger the associated procedure
BindEvent(#PB_Event_RenderFrame, @RenderFrame())
CreateSprite(0, 64, 64)
If StartDrawing(SpriteOutput(0))
Circle(32, 32, 25, RGB(255, 0, 0)) ; Red circle
StopDrawing()
EndIf
OpenWindowedScreen(WindowID(0), 20, 20, 800, 600)
FlipBuffers() ; trigger the rendering
Christos
Re: Sprite generation MUST be after openscreen ?
no, I meant that it is always easier for those who want to help if they have a code that can be used to trace the problem.plouf wrote:if you mean about sample code, does it happens otherwise to ANYONE else ?!
confirmed.
If there is no opened window screen, StopDrawing (stopDrawingCallback) throws an error because spider.screen.renderer is null.
Re: Sprite generation MUST be after openscreen ?
Yes, you need a screen, like in PureBasic
Re: Sprite generation MUST be after openscreen ?
OK, I'm not very familiar with the Screen- and 2DDrawing- things, so I didn't know that.Fred wrote:Yes, you need a screen, like in PureBasic
But wouldn't it be a good idea to get a message if the screen was not initialised?
Re: Sprite generation MUST be after openscreen ?
Unfortunately, there is no runtime debugger yet in spiderbasic, so it's possible to do without doing it in the real command (which I would like to avoid)
Re: Sprite generation MUST be after openscreen ?
How about a debug output for JavaScript errors (as in this case)? I think that many SpiderBasic programmers don't know (or don't think about) that they should open the Developer Console when an error occurs that they can't explain.Fred wrote:Unfortunately, there is no runtime debugger yet in spiderbasic, so it's possible to do without doing it in the real command (which I would like to avoid)
Code: Select all
! window.onerror = function(message, source, lineno, colno, error) {
! spider.debug.Print("JavaScript-Error!");
! spider.debug.Print(message);
! spider.debug.Print("(See developer console for more information)");
! // spider.debug.Print(source);
! // spider.debug.Print("Line: " + lineno + "; Col: " + colno);
! // spider.debug.Print(error);
! }
Re: Sprite generation MUST be after openscreen ?
firstly MUST be mention in doc's this is crucial imho
then, i dont know if it possible, but cant the compiler during "compiling" have in mind that if it sees sprite commands before a openscreen throw a "warning" ?!?
then, i dont know if it possible, but cant the compiler during "compiling" have in mind that if it sees sprite commands before a openscreen throw a "warning" ?!?
Christos
Re: Sprite generation MUST be after openscreen ?
Good idea about the onerror(). I will update the doc as well.