Strange text behavior with offset viewport

Discussion about using Moai SDK - post questions, issues, and ideas here.

Moderators: naturally, seebs, ezraanderson

Strange text behavior with offset viewport

Postby WhaleFood » Sun Jan 28, 2018 11:08 pm

I'm trying to update my project to the latest community version of moai and I'm seeing some very odd behavior with textboxes. In the following code, for some reason only the words "one" and "two" show. I think it might have something to do with the viewport offset?

Code: Select all
  1.  

  2. -- standard setup

  3. local screenWidth = 640

  4. local screenHeight = 900

  5.  

  6. MOAISim.openWindow("Window",screenWidth,screenHeight)

  7.  

  8. local viewport = MOAIViewport.new()

  9. viewport:setSize(screenWidth,screenHeight)

  10. viewport:setScale(screenWidth, -1* screenHeight)

  11. viewport:setOffset( -1,1);

  12. local layer = MOAILayer2D.new ()

  13. layer:setViewport ( viewport )

  14. MOAISim.pushRenderPass ( layer )

  15.  

  16. -- create font

  17. charcodes = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 .,:;!?()&/-'

  18. font = MOAIFont.new ()

  19. font:loadFromTTF ( './arial-rounded.TTF', charcodes, 7.5, 163 )

  20.  

  21.  

  22. -- add text boxes

  23.  

  24. local function addTextbox ( str, left, height )

  25.  

  26.         local textbox = MOAITextBox.new ()

  27.         textbox:setString ( str)

  28.         textbox:setFont ( font )

  29.         textbox:setTextSize ( 7.5, 163 )

  30.         textbox:setRect ( left, height, screenWidth, screenHeight)

  31.         textbox:setAlignment ( MOAITextBox.LEFT_JUSTIFY, MOAITextBox.TOP_JUSTIFY);

  32.         layer:insertProp ( textbox )

  33. end

  34.  

  35. addTextbox ("one", screenWidth/6,screenHeight/6 )

  36. addTextbox ("two", screenWidth/4, screenHeight/4)

  37. addTextbox ("three", screenWidth/2, screenHeight/4)

  38. addTextbox ("four", screenWidth/4, screenHeight/2)

  39.  

WhaleFood
 
Posts: 14
Joined: Wed Mar 20, 2013 6:53 pm

Re: Strange text behavior with offset viewport

Postby WhaleFood » Tue Jan 30, 2018 6:53 pm

Figured out a workaround. Making the viewport way bigger than the window (I chose 2x) seems to fix the issue.
WhaleFood
 
Posts: 14
Joined: Wed Mar 20, 2013 6:53 pm

Re: Strange text behavior with offset viewport

Postby naturally » Mon Feb 05, 2018 9:38 am

Was this an Apple-specific issue?
Image - Don't Be Patchman - a sneak-and-grow adventure!
User avatar
naturally
 
Posts: 716
Joined: Thu Aug 29, 2013 8:05 pm
Location: Canada


Return to Moai SDK

Who is online

Users browsing this forum: No registered users and 0 guests

cron

x