I am super new to lua but learning! I'm starting with the ebook example and I would like an image to fade in. So far my super code I have this:
self.courtarrow = Bitmap.new(TextureRegion.new(Texture.new("gfx/arrows.png", true )))
self.courtarrow:setX(650)
self.courtarrow:setY(100)
yeah.. nothing special just the coordinates. the graphic section of the guide to lua isnt complete so as a newbie im not sure how to get it working
thanks for any pointers where to find out to do this im sure simple code
Comments
Have a look at the Fading Stars sample that comes with Gideros Studio
cheers
evs
By the way , the solution of your problem is adding child. You should use that self:addChild(self.courtarrow) then you have to call that class in the main like that blabla=ClassName.new()
stage:addChild(blabla)
Mert
Dislikes: anneMurielle
I've tried however, the image does not appear.
Page0 = gideros.class(Sprite)
function Page0:init( pageNo, parent)
self.no = pageNo
self.background = Bitmap.new(TextureRegion.new(Texture.new("gfx/page4.png", true)))
self.courtarrow = Bitmap.new(TextureRegion.new(Texture.new("gfx/arrows.png", true )))
self.courtarrow:setX(650)
self.courtarrow:setY(100)
self:addChild(self.background)
self:addChild(self.courtarrow)
end
function Page0:onTimer(timer)
local arrow = Bitmap.new(Texture.new("gfx/star.png"))
arrow:setPosition(400, 100, timer:getCurrentCount() * 80 - 60)
timer = Timer.new(500, 5)
timer:addEventListener(Event.TIMER, onTimer, timer)
timer:start()
local fade = Fade.new(arrow)
stage:addChild(fade)
end
Of course when you come to write your apps, then you will be using classes, but just to test things out while you're learning, it's easier not to.
This will add an image to the stage and fade it in:
change it to
timer = Timer.new(100,0)
and
currentAlpha = currentAlpha + 0.01
for a smoother fade in.
----
In your code, where is the Fade class defined?
edit: maybe not, i see the image on every page now..:(
Try this - this is my entire code for page0.lua, which fades in a bird at the top left.
http://www.giderosmobile.com/documentation/classes_in_gideros.html
http://www.giderosmobile.com/documentation/events.html
(That might not be the best way to do that in this ebook example, it's just a quickie )
local mc = MovieClip.new{
{1, 100, sprite1, {x = {0, 200, "linear"}}},
{50, 150, sprite1, {y = {0, 100, "linear"}}, {alpha = {0, 1, "easeOut"}}},
{100, 200, sprite2, {x = {0, 200, "linear"}}},
}
---------------------------------------