why i cant change anything from stage to self? you know i dont want my pictures to stay at screen when scenemanager changes scene. and why everything disapear from scene after few seconds
options = gideros.class(Sprite)
function options:init()
about = Bitmap.new(TextureRegion.new(Texture.new("images/options.png" , true)))
exit = Bitmap.new(Texture.new("images/options1.png"))
local butto = Button.new(exit, about)
self:addChild(butto)
butto:setPosition(0, 0)
butto:addEventListener("click", function()
sceneManager:changeScene("start", 1, SceneManager.changeWithoutAnim)
end)
end
local buttonUp = Bitmap.new(Texture.new("images/4.png"), true)
local buttonDown = Bitmap.new(Texture.new("images/4.png"), true)
local button = Button.new(buttonUp, buttonDown)
button:setPosition(250,300)
---------------------------------
stage:addChild(button)
---------------------------
laweczka=Bitmap.new(Texture.new("images/komiks1.png"))
laweczka:setPosition(0,0)
stage:addChild(laweczka)
local frames = {}
frames[1] = Bitmap.new(Texture.new("images/komiks1.png"))
frames[2] = Bitmap.new(Texture.new("images/komiks2.png"))
frames[3] = Bitmap.new(Texture.new("images/komiks3.png"))
frames[4] = Bitmap.new(Texture.new("images/komiks4.png"))
frames[5] = Bitmap.new(Texture.new("images/komiks5.png"))
local mc1 = MovieClip.new{
{1, 10, frames[1]},
{10, 20, frames[2]},
{20, 30, frames[3]},
{30, 40, frames[4]},
{40, 50, frames[5]},
}
mc1:setPosition(0,0)
-----------------------------------------------------------------------
self:addChild(mc1)
-------------------------------------------------------------------------
mc1:gotoAndPlay(1)
mc1:setGotoAction(50,1)
mc1:setStopAction(50)
local click=0
button:addEventListener("click",
function()
print("Started button", click)
click = click + 1
end)
Comments
problem is that you have an init methos
functions option:init()
--here self is valid
print(self) --prints table
end
--outside the scope self is nil
print(self) --prints nil