is it difficult to make the text which will be displayed with animation?

is there someone who can tell me?. how to display text, which will gradually be printed on the player’s eyes. I almost completed my game and with this job I have problems. need to display the text that will itself print. the full text is set in code.

@creative_novice I’m not sure what you’re asking printed on the players eyes or display text that will itself print. There 2 ways to display text, that’s with the text or print commands. Can you explain more.

Perhaps progressively displaying a string “letter-by-letter”?

Are you after something like this.

EDIT: Depending on how you want to animate this, you could use tweens.

function setup()
    tab={}
    str="Here is some text. I dont know how you want to animate it."
    split()
    rot=0
end

function draw()
    background(40, 40, 50)    
    fill(255)
    for a,b in pairs(tab) do
        pushMatrix()
        translate(WIDTH/2,HEIGHT/1.5-a*40)
        rotate(rot)
        text(b,math.random(-3,3),0)
        popMatrix()
        rot=rot+math.random(-5,5)
    end
end

function split()
    for t in string.gmatch(str,"%a+") do
        table.insert(tab,t)
    end    
end

Here’s some animation using tweens.

function setup()
    tab={}
    table.insert(tab, txt ("Here is some text.",8,200,600,300,500))
    table.insert(tab, txt ("Tap the screen to start.",8,300,200,300,500))
end

function draw()
    background(0)
    for a,b in pairs(tab) do
        b:draw()   
    end
end

function touched(t)
    if t.state==BEGAN then
        for a,b in pairs(tab) do
            b:touched(t)   
        end
    end
end

txt=class()

function txt:init(str,t,xs,ys,xe,ye)
    self.str=str
    self.col=color(0, 244, 255, 255)
    self.starts={x=xs,y=ys}
    self.ends={x=xe,y=ye}
    self.time=t
end

function txt:tw()
    tween(self.time,self.starts,self.ends,tween.easing.sineOutIn,
        function() self.str="" end)
end

function txt:draw()
    fill(self.col)
    text(self.str,self.starts.x,self.starts.y)
end

function txt:touched(t)
    self:tw()
end

Here’s another example.

displayMode(FULLSCREEN)
supportedOrientations(LANDSCAPE_ANY)

function setup()
    tab={}
    str="This is another example showing how to animate text. You can display whatever you want."
    for z=1,#str do
        table.insert(tab,string.sub(str,z,z))
    end
    t=0
    d=360/#tab-.01
end

function draw()
    background(40, 40, 50)
    for a,b in pairs(tab) do
        t=t+d
        pushMatrix()
        translate(100+a*10,300+math.sin(math.rad(t))*200)
        text(b,0,0)
        popMatrix()
    end
end

how to add recent and proposed animations in one of the pages this code?

    function setup()
        gameMode = Str1
    end
    
    function draw()
        background(40, 40, 50)
        gameMode()
        strokeWidth(5)
    end
    
    function Str1()
        background(255, 255, 255, 255)
        sprite("Platformer Art:Block Grass", WIDTH/2, 384)  --70x70 Sprite size
        font("Baskerville-BoldItalic")
        fill(0, 0, 0, 255)
        text("1", WIDTH/2, HEIGHT/2.4)
    end
    
    function Str2()
        background(255, 255, 255, 255)
        sprite("Platformer Art:Block Brick", WIDTH/1.5, 384)   --70x70 Sprite size
        font("Baskerville-BoldItalic")
        fill(0, 0, 0, 255)
        text("2", WIDTH/1.5, HEIGHT/2.4)
    end
    
    function Str3()
        background(255, 255, 255, 255)
        sprite("Planet Cute:Dirt Block", WIDTH/2, 384)   --101x171 Sprite size
        font("Baskerville-BoldItalic")
        fill(0, 0, 0, 255)
        text("3", WIDTH/2, HEIGHT/2.4)
    end
    
    function touched(t)
        if gameMode == Str1 then
            if t.x>WIDTH/2-35 and t.x<WIDTH/2+35 and 
                    t.y>384-35 and t.y<384+35 and t.state == ENDED then
                --music("Dropbox:Test")
                gameMode = Str2
            end
        end
        if gameMode == Str2 then
            if t.x>WIDTH/1.5-35 and t.x<WIDTH/1.5+35 and 
                    t.y>350 and t.y<450 and t.state == ENDED then
                gameMode = Str3
            end
        end
        if gameMode == Str3 then
            if t.x>WIDTH/2-50 and t.x<WIDTH/2+50 and 
                    t.y>384-85 and t.y<384+85 and t.state == ENDED then
                gameMode = Str1
            end
        end
    end

WOW! My game will be ready in a few days. Popularity codea should rise up

So first it’s not called gamemode = Strl, it’s called gamemode = Strl() I mean the brackets. If you don’t use brackets it will return nil.

@TokOut please don’t try to answer questions until you’ve learned some basic lua. gameMode here is a function pointer. You don’t use the brackets when setting a pointer, because you are deferring the call until it is needed, in this case, in the draw loop gameMode(). This is a very common technique in finite state machines.

@creative_novice you’ve been given lots of samples in this thread. Why don’t you try incorporating one of them yourself? As it is, we have no idea what text you are trying to display, when, or why. You’ve given us almost nothing to go on. I think your game might need more than a few days :slight_smile:

no. the game definitely will be completed within a few days. if I gave you full instructions, then you could explode the brain :stuck_out_tongue: . you helped me a lot and based on your examples and your knowledge I made a very interesting game. I just want to do something interesting. the basics of Lua I know is normal.
thank you Google translator

thinking. will release the game as it is. when will the money turn to more detailed help.
who could help the currency? and for how much?

if there are Russian, it will be still better

I’m russian, help needed.