Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Just want to know why it's not working.
Started by nosoyhackercodigo Jul 11 2018 11:24 AM

3 replies to this topic

Best Answer roaminggamer , 11 July 2018 - 12:16 PM

@ldurniat is correct.

 

Additionally, variable extraction code is written backwards. 

 

Why are you assigning values to the event?  That won't do anything.

 

 

This is the correction I would suggest (with @ldurniat's change too):

local centerX, centerY = display.contentCenterX, display.contentCenterY
local square = display.newRoundedRect( centerX, centerY, 32, 32, 12 )

local function makeItBiggerByEasing(event)
  local mySquare = event.target
  local myTransition = transition.to( mySquare, 
                                      { width = mySquare.width + 5,
                                        height = mySquare.height + 5, 
                                        time = 350, transition = easing.OutQuad } )
end


square:addEventListener("tap", makeItBiggerByEasing)

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

nosoyhackercodigo

[GLOBAL: userInfoPane.html]
nosoyhackercodigo
  • Observer

  • 17 posts
  • Corona SDK

Can someone explain me why it is sending this message?
 
error ---> main.lua:6: attempt to perform arithmetic on global 'width' (a nil value) <---
 
local centerX, centerY = display.contentCenterX, display.contentCenterY
local square = display.newRoundedRect( centerX, centerY, 32, 32, 12 )

local function makeItBiggerByEasing(event)
  event.target = mySquare
  local myTransition = transition.to( mySquare, 
{ width = width + 5,height = height + 5, time = 350, transition = easing.OutQuad } )
end


square:addEventListener("tap", makeItBiggerByEasing)

I am using a Chromebook C720 with Elementary OS as operative system and PlayOnLinux to run Corona,

any ideas?



[TOPIC: post.html]
#2

ldurniat

[GLOBAL: userInfoPane.html]
ldurniat
  • Contributor

  • 355 posts
  • Corona SDK

Hi nosoyhackercodigo,

 

You should replace width with mySquare.width. The same think apply to height field. So code

width = width + 5

change to

width = mySquare.width + 5

Read more

 

Have a nice day:)

 

 

ldurniat


Edited by ldurniat, 11 July 2018 - 12:00 PM.


[TOPIC: post.html]
#3

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 6,981 posts
  • Corona SDK

  Best Answer

@ldurniat is correct.

 

Additionally, variable extraction code is written backwards. 

 

Why are you assigning values to the event?  That won't do anything.

 

 

This is the correction I would suggest (with @ldurniat's change too):

local centerX, centerY = display.contentCenterX, display.contentCenterY
local square = display.newRoundedRect( centerX, centerY, 32, 32, 12 )

local function makeItBiggerByEasing(event)
  local mySquare = event.target
  local myTransition = transition.to( mySquare, 
                                      { width = mySquare.width + 5,
                                        height = mySquare.height + 5, 
                                        time = 350, transition = easing.OutQuad } )
end


square:addEventListener("tap", makeItBiggerByEasing)


[TOPIC: post.html]
#4

nosoyhackercodigo

[GLOBAL: userInfoPane.html]
nosoyhackercodigo
  • Observer

  • 17 posts
  • Corona SDK

It's working!

 

You guys respond really faster!! It's amazing!

 

Assigning values to the event.....My mistake, sorry.

 

Thank you Idurniat and roaminggamer, you both are awesome people in this community.

 

Keep doing the good work.




[topic_controls]
[/topic_controls]