1) To use Screen (that is windows) you first need to create them:
screen=Screen.new(0)
2)
application:setKeyboardVisibility(true)
should pop up the native keyboard and return true if it was able to do so. 3) Seems like you forgot to specify the arg to Core.random[Seed], which specify which random generator to use. Basically there is guarantee that lua math.random will produce the same random sequence for a given seed on all platforms, as it relies on OS provided random functions. Core.random() guarantees this.
THX @hgy29 ! 1) What is the actual purpose of "Screen.new"? (I've tried to search, but didn't find any info about it) Is it made for managing scenes or layers?
3) Which arguments should be added? When I test this code, results are always randomized, there's no consistancy:
function onMouseDownFunc(event)print("random num:",Core.random(10,200,300))end
stage:addEventListener(Event.MOUSE_DOWN, onMouseDownFunc)
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
The Lua built-in random number generator may produce the same sequence on one device (if you set the seed), but on a different os or brand of device it may produce a different sequence. The core version will produce the same sequence on all devices - if you set the seed.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
It works ok. Can number of arguments be reduced to one? Like:
function day1:init()
addYantra(self)end
How to transform argument 'self' into the string with the name of the class? "table: 0x7f980e0c28" --> "day1"
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Guys is it inevitable that TTFont is lagging in my case? Or I can do something to optimize it? Maybe pre-load it on scenes somehow?
Inside 'init.lua' I have:
smallFont = TTFont.new("fonts/segoeuil.ttf", 14, false)function addTextWrap(parent)local str="Lorem ipsum dolor sit amet, consectetur adipiscing elit.\nSed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."local planetText = TextWrap.new(str, 300, "left", 5, smallFont)
planetText:setAnchorPoint(.5,.5)
planetText:setPosition(centerX, 200)
parent:addChild(planetText)end
On PC it doesn't lag at all, but on Android Player it slightly lags when Scene Manager loads the scene 'day4' with TTFont. Scenes without TTFont don't lag. 'segoeuil.ttf' weights 790kb p. s. my android device has decent perfomance (xiaomi note 4x)
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
local chrs=""
fonts={{file="zombie.ttf",sizeMult=1.0},
{file="cyrillic.ttf",sizeMult=1.0},
{file="japanese.ttf",sizeMult=0.8},
{file="arabic.ttf",sizeMult=1.0}}
smallFont=TTFont.new(fonts,33,chrs,3)
font=TTFont.new(fonts,66,chrs,3)
fontLarge=TTFont.new(fonts,132,chrs,3)
That will automatically try add characters from the fonts in turn (until it gives up) as they are needed. The '3' gives a nice smoothing to the font. The Japanese font was a little large compared to the others so the size is set slightly smaller.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
Guys I'm curious why Gideros' installation size is so big compared to other frameworks and even engines? 741mb is pretty huge.
It's very intriguing - what is there so huge inside Gideros that is not inside other engines&frameworks. love2d weights 3mb, Corona is 83mb, Defold is 300+mb, Godot is 20, etc.
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
The big size is mostly due to all precompiled export templates and players gideros has: libs with associated debugging information can be above 100MB per platform. They are particularly huge on windows phone, windows 8, iOS and Apple TV. Take a the size of players and templates folders in your gideros installation, you will see what I mean.
I think it would be best (long term) if the template folders were downloaded on demand. That way they could be updated independently of each other and the main editor/texture packer, etc.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
uh, I've made primitive rpg-dialogue: but I'm not sure guys if it is the most optimal way?
dialogue1 ="Hello my friend! How are you?"
displayDialogue = TextField.new(nil, "")
displayDialogue:setPosition(200,200)
stage:addChild(displayDialogue)
i =0function onNewTimerFunc()
i+=1if i <= #dialogue1 then
displayDialogue:setText(displayDialogue:getText()..string.sub(dialogue1,i,i))else--do some stuff after dialogue completedprint("completed!")
newTimer:stop()endend
newTimer = Timer.new(100,0)
newTimer:addEventListener(Event.TIMER, onNewTimerFunc, newTimer)
newTimer:start()</pre>
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
@Apollo14, here is a VERY quick and DIRTY example of one possible solution..
font = Font.getDefault()
brush = TextField.new(font, "A")
brush:setTextColor(0x774411)local canvas = RenderTarget.new(160, 128)
canvas:clear(0x77bbff, 1)
textBox = Bitmap.new(canvas)
textBox.width =160
textBox.height =128
textBox.speed =0.15-- speed that the box plops out text
textBox.counter =0-- used for timing text plops
textBox.pos =0-- start at 0
textBox.x =0
textBox.y = font:getAscender()
textBox.done =false
textBox.text ="Well this is some text. When the cursor exceeds the width of the container it should wrap but will be very messy. Here ends the lesson <img class="emoji" src="https://forum.gideros.rocks/resources/emoji/lol.png" title=":D" alt=":D" height="20" />"function onEnterFrame(e)local dt = e.deltaTime
ifnot textBox.done thenlocal counter = textBox.counter + dt
if counter >= textBox.speed then
counter = counter - textBox.speed -- reset counterprint("boo")local x, y = textBox.x, textBox.y
print(x, y)local pos = textBox.pos + 1-- increment characterif pos > #textBox.text then
textBox.done =trueelse
textBox.pos = pos
print(textBox.pos)local char = textBox.text:sub(pos, pos)-- next character in string
brush:setText(char)-- brush text setlocal charWidth = font:getAdvanceX(char)-- width of current charif x + charWidth > textBox.width then
x =0-- wrap line
y = y + font:getAscender()end
brush:setPosition(x, y)-- position brush
canvas:draw(brush)-- print the new char into the canvas
textBox.x, textBox.y = x + charWidth, y -- save x and yendend
textBox.counter = counter
endend
stage:addChild(textBox)
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)
So basically we use a RenderTarget as our bitmaps texture. This means we can draw into the RenderTarget and it gets updated in realtime on the screen. Then we just make our way through the text char by char and position/draw it to the RenderTarget until we are done.
If you are using a fixed width font then you can use formatting to ensure it doesn't wrap in the middle of a word.
It could be greatly enhanced by making it's own class but it's 11pm here and I am tired
Guys, if I need to create 7 objects (pixel1, pixel2, pixel3, etc.), what is the correct syntax?
for i=1,7dolocal pixel..i = Pixel.new(blackColor,.1,appW,42)--'pixel..i' obviously doesn't work
self:addChild(pixel..i)end
Or it can be done only with array?
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
@Apollo14 it all depends on how you wish to use them. the original Pixel class was very good and it still is but now there are two ways to create a Pixel
As a rectangular colored shape.
As a rectangle with an image mashed inside it.
You can opt to add the pixels to a table...
-- create pixels as elements in a Tablelocal pixels ={}for i =1, 7dolocal pixel = Pixel.new(blackColor, 0.10, appW, 42)
pixels[#pixels + 1]= pixel
self:addChild(pixel)end-- to iterate through the pixels using this method..for i = #pixels, 1, -1dolocal pixel = pixels[i]-- do stuff with pixelend
Or hang them off a Sprite...
-- create pixels as children of a Spritelocal pixels = Sprite.new()for i =1, 7do
pixels:addchild(Pixel.new(blackColor, 0.10, appW, 42))end
self:addChild(pixels)-- to iterate through the pixels using this method..for i = pixels:getnumChildren(), 1, -1dolocal pixel = pixels:getChildAt(i)-- do stuff with pixelend
@Apollo14, here is a VERY quick and DIRTY example of one possible solution.. ... It could be greatly enhanced by making it's own class but it's 11pm here and I am tired
@antix would you be so kind to create a class for RPG-style dialogues when you'll have some free time? I think it could be extremely handy, because dialogues make game very cute Thanks!
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
if currLocale:sub(1, 3)=="de_"then-- do cool stuffend-- and do something like...local localeActions ={["de_"]=function()print("Ja!")end,
["en_"]=function()print("Yes!")end,
["fr_"]=function()print("Oui!")end}
localeActions[currLocale:sub(1, 3)]()
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
@Apollo14 There was a lag in one of the TTFont combinations (when you supply an empty string) - that has now been fixed in either the latest release or the upcoming 2018.3 release (I can't remember).
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
Comments
3) Seems like you forgot to specify the arg to Core.random[Seed], which specify which random generator to use. Basically there is guarantee that lua math.random will produce the same random sequence for a given seed on all platforms, as it relies on OS provided random functions. Core.random() guarantees this.
Likes: SinisterSoft
1) What is the actual purpose of "Screen.new"? (I've tried to search, but didn't find any info about it)
Is it made for managing scenes or layers?
3) Which arguments should be added?
When I test this code, results are always randomized, there's no consistancy:
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
https://deluxepixel.com
Core.random(algorithm to use[,start][,end])
Currently the algorithm to use should be 0
Your example corrected:
Core.randomSeed(0,10)
randNum = Core.random(0,1,10)
print(randNum)
Likes: Apollo14
https://deluxepixel.com
Likes: antix
Guys, I'm trying to write a function:
I have 7 scenes: 'day1.lua', 'day2.lua'...'day7.lua'
And 7 pics: 'day1pic.png', 'day2pic.png'...'day7pic.png'
I've added function to my 'init.lua':
Can number of arguments be reduced to one? Like:
"table: 0x7f980e0c28" --> "day1"
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Likes: Apollo14
Likes: Apollo14
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Inside 'init.lua' I have:
'segoeuil.ttf' weights 790kb
p. s. my android device has decent perfomance (xiaomi note 4x)
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Likes: Apollo14, antix
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Likes: Apollo14
Likes: oleg, Apollo14
https://deluxepixel.com
It's very intriguing - what is there so huge inside Gideros that is not inside other engines&frameworks.
love2d weights 3mb, Corona is 83mb, Defold is 300+mb, Godot is 20, etc.
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Likes: Apollo14, antix
https://deluxepixel.com
(when text appears symbol-by-symbol)
Did somebody make it before?
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
but I'm not sure guys if it is the most optimal way?
Likes: oleg
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
If you are using a fixed width font then you can use formatting to ensure it doesn't wrap in the middle of a word.
It could be greatly enhanced by making it's own class but it's 11pm here and I am tired
Likes: Apollo14
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Likes: Apollo14
Thanks!
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
One of the example games in my book (a puzzle based platformer) will need such a system though, so you never know
Likes: Apollo14
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Likes: Apollo14, antix
Maybe something like this https://github.com/scottrules44/wallpaper-demo/blob/master/main.lua (beer sdk)
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Likes: Apollo14
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
Likes: Apollo14
https://deluxepixel.com