Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to implement the appearance effect for a button?
Started by peterbayrosh Jan 07 2020 05:08 AM

4 replies to this topic
corona sdk widgets

Best Answer sporkfin , 07 January 2020 - 07:20 AM

Hi Petyr, just to clarify, you are asking how to get your "continuebutton" to fade in?  If so, I see that it is in a group called "other" so maybe . . .

other.alpha = 0
transition.to( other, {time = 1000, alpha = 1} )

Is that what you were asking?

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

peterbayrosh

[GLOBAL: userInfoPane.html]
peterbayrosh
  • Observer

  • 5 posts
  • Corona SDK

Hello! My name is Petyr. I cannot realize the effects of a button appearance. I would like the button ("tap to continue..") to appear slowly with the "fade" effect. The button  is on the modal scene and not belongs to the scene group.

I have attached the photo for clarity.

 

Attached File  9c3ef1e41e2e93789cf985756c641b8a.png   306.03KB   0 downloads

 

Thanks!



[TOPIC: post.html]
#2

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 822 posts
  • Corona SDK

@Peter, please show us your code.  Remember to use the <> button in the control bar make your code display as code.



[TOPIC: post.html]
#3

peterbayrosh

[GLOBAL: userInfoPane.html]
peterbayrosh
  • Observer

  • 5 posts
  • Corona SDK

local function gotoscenepause()             -- go to the modal scene where my button is
	local options =                     -- (You can ignore it)
	{
		isModal = true,
		effect = "slideLeft",
		time = 450,
	}
	composer.showOverlay( "pause_scene" , options )
end

local function onstopBtnRelease()
	gotoscenepause()
	return true	
end

-- below is a modal scene script
-- theres a lot of unnecessary  there, so I left the code associated with my button

local composer = require( "composer" )
local scene = composer.newScene()
local widget = require "widget"
widget.setTheme("widget_theme_android")
local continuebutton
local function oncontinueBtnRelease()
	local options =
	{
		effect = "fade",
		time = 350,
	}
	composer.hideOverlay("pause_scene", options)
	return true	-- indicates successful touch
end

function scene:create( event )
	local sceneGroup = self.view
	local other = display.newGroup()
	continuebutton = widget.newButton
	{
		label = "tap to continue...",
		font="Helvetica",
		width=(height2-(height2-(height2/2.5)))+30, height=width2,
		onRelease = oncontinueBtnRelease	-- event listener function
	}
	continuebutton.x = (height2-(height2-(height2/2.5)))/2+20
	continuebutton.y = width2/2

	other:insert( continuebutton )
end

function scene:show( event )
	local sceneGroup = self.view
	local phase = event.phase
	
	if phase == "will" then
	
	elseif phase == "did" then
		
	end	
end

function scene:hide( event )
	local sceneGroup = self.view
	local phase = event.phase
	
	if event.phase == "will" then
		
	elseif phase == "did" then

	end	
end

function scene:destroy( event ) 
	local sceneGroup = self.view
	if continuebutton then
		continuebutton:removeSelf()	-- widgets must be manually removed
		continuebutton = nil
		composer.removeScene('pause_scene')
	end	
end

---------------------------------------------------------------------------------


scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )

-----------------------------------------------------------------------------------------

return scene

Sorry for the wait.

 

 



[TOPIC: post.html]
#4

sporkfin

[GLOBAL: userInfoPane.html]
sporkfin
  • Contributor

  • 822 posts
  • Corona SDK

  Best Answer

Hi Petyr, just to clarify, you are asking how to get your "continuebutton" to fade in?  If so, I see that it is in a group called "other" so maybe . . .

other.alpha = 0
transition.to( other, {time = 1000, alpha = 1} )

Is that what you were asking?


  • peterbayrosh likes this

[TOPIC: post.html]
#5

peterbayrosh

[GLOBAL: userInfoPane.html]
peterbayrosh
  • Observer

  • 5 posts
  • Corona SDK

So this is what I needed. You helped a lot Mr. sporkfin. Thank you very much!




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: corona sdk, widgets