Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Types of widgets
Started by Jack G Jan 09 2019 10:10 PM

3 replies to this topic
shapes
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Jack G

[GLOBAL: userInfoPane.html]
Jack G
  • Observer

  • 1 posts
  • Corona SDK

Hello, 

 

I'm a 50 yr old guy trying to learn something that a lot of kids can do with their eyes closed. I tried the Lua 5.1 Reference Manual, but that was like learning Algebra all over again.  I completed Chapter 1 — Creating an App, tapping the balloon was easy, still working on Chapter 2 — Upward & Onward. 

 

This is going to be my first question in a long series of questions, I'm not clear on widgets. I checked the widget.newButton() page, I copied and pasted the Shape example for the rounded rectangle button, but I'm not clear on what type of buttons I can create.

 

Is there a replay widget like the picture I attached?

 

What widget shapes are available or is it better just to upload a picture?  My goal is to make an app, no animation, not yet.

 

 

Thank you

Attached Files



[TOPIC: post.html]
#2

agramonte

[GLOBAL: userInfoPane.html]
agramonte
  • Contributor

  • 918 posts
  • Corona SDK

Ummm. the button widget will take any image you provide. I am a little confused when you say upload. Just place that image in the app folder and when creating the button widget reference it.

 

From the example:

local button1 = widget.newButton(
    {

        width = 240,
 
        height = 120,
  
        defaultFile = "buttonDefault.png", -- your button file here.
  
        label = "button",
 
        onEvent = handleButtonEvent -- need to create this event

    }
)
 
-- Center the button
button1.x = display.contentCenterX

button1.y = display.contentCenterY

And 50 is the new 35. It isn't that old. We have plenty of 50+ here based on the references they make. I won't mention names because I don't want to out them.



[TOPIC: post.html]
#3

Appletreeman

[GLOBAL: userInfoPane.html]
Appletreeman
  • Contributor

  • 420 posts
  • Corona SDK

 

 

And 50 is the new 35. It isn't that old. We have plenty of 50+ here based on the references they make. I won't mention names because I don't want to out them.

 

I'm (very nearly) 50 and proud of it!



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,133 posts
  • Corona SDK

57 and still rockin' it...

 

widget.newButton has different ways to do buttons: you can do a single graphic or a two graphic version (pressed, unpressed), you can have it done with vector objects (squares, circles, rounded rectangles, triangles, etc.) with text written on top.

 

People making games want buttons that fit the theme of their particular game. Your replay graphic above may work for you but it probably won't work for 99% of other Corona developers. Other than buttons and such that look like iOS and Android standard UI elements, it's expected that you will provide all artwork in a style that fits your needs.

 

Then there is the question of just what does "Replay" mean? For a tic-tac-toe game, replay may mean clearing the board and setting the player to X. But for a checkers game, replay means putting 12 red checker pieces and 12 black checker pieces back in their starting positions and replaying PacMan is restoring all the dots and powerups, putting the ghosts back in their cage and setting a score back to 0. Every game is completely different with regards to that. There is no standard way to create a replay widget.

 

Instead, widget.newButton() lets you decided how it looks, which includes providing images for the button states and you write a function to react to when the button is pressed. You can name it your replayButton and create a function named onReplayPressed() which does the things your game needs to do to reset.

 

Rob




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: shapes