Re: Manual Questions
Status: Alpha
Brought to you by:
cwalther
From: Christian W. <cwa...@gm...> - 2009-04-03 19:00:43
|
> 1. In the pipmak demo I want pipmak to show a text reaching the end > of game > in the middle of screen, say > > > "Congratulations, you can now advance to level 2." > > > I am on windows. Should I use image:drawtext to do this? if so how? > > or I should use it as slide? In other words, creating an image file > showing/displaying the text, "congratulations" and then having pipmak > display that in particular even. You can do either (or even both at the same time). It depends on what exactly you want to do, there are a lot of combinations. If you want to display the "congratulations" box on a screen of its own, you can make it a separate slide. If you want to display it on top of a panorama, make it a slide with transparency (scaled to fit the screen) or a panel (kept at screen resolution) and display it as an overlay. If you want to display it on top of one particular slide, you can make it a patch on that slide node. If you are satisfied with Pipmak's text rendering and don't need any fancy effects on the text, or want to be able to change the text easily, you can use image:drawtext. Otherwise, you draw the text yourself in a graphics program and incorporate the result as an image. Here's a working example of a slide with a background picture and a patch containing drawn text (using a built-in image and font for demonstration, you will want to use your own image and perhaps your own font): -------- slide "../resources/missing.png" patch { x = 0, y = 50, image = pipmak.newimage(128, 20):color(1, .5, 0):drawtext(64, 0, "congratulations", "../resources/Vera.ttf", 16, pipmak.center) } -------- You could also draw the text directly on the background image: -------- local img = pipmak.newimage("../resources/missing.png") img:color(1, .5, 0):drawtext(64, 50, "congratulations", "../resources/ Vera.ttf", 16, pipmak.center) slide (img) -------- Or even create the whole background image programmatically: -------- slide (pipmak.newimage(640, 480):color(1, .8, .5):fill(150, 200, 340, 80):color(.4, .2, 0):drawtext(320, 210, "congratulations", "../ resources/VeraBd.ttf", 24, pipmak.center)) -------- Does that help? I admit that this is all a bit complicated and low- level, that's why Andrea has created a more user-friendly text display system on top of it that will be integrated into the next version of Pipmak: http://thread.gmane.org/gmane.games.devel.pipmak.user/454 > 2. node:getcurrentnode() returns the number of the current > background node. > Is there any command that returns the the number of the last visited > node? No. You need to keep track of that yourself if you need it, by adding an onenternode handler to every node that takes the node number and appends it to some list in the state table, or something. You could put that into its own file and include it in all the nodes using pipmak.dofile() to avoid duplication. > 3. I am going to use print.pipmak for debugghing. The following code > give me > an error: > > > local junk=1 // also without local, ie, global > > print.pipmak( "junk is " , junk) > > it gives me the following error: attemp to index global "print' ( a > function > value) > > > what am I doing wrong? What you want is "pipmak.print", not "print.pipmak". The function that's stored under the name "print" in the table "pipmak". What you're trying here is to get the entry named "pipmak" in the global variable "print", which doesn't work because "print" is not a table but a function (one that prints to standard output, which is of limited use in Pipmak). > 4. I use the pipmak.gotnode() to go to a particular node. How can I > ask > pipmak to say go to node 99 after 10 seconds? The following doesn't > work: > > pipmak.gotonode(99,10) pipmak.schedule(10, function() pipmak.gotonode(99) end) > -Christian |