Hello,
One of the most powerfull features of Corona and RapaNui/MOAI is the way
you can simply create animations from Texture Packs (also known as Spritesheets
or Texture Atlasses). Is it already possible to use this on the same way in Gideros
like the other tools do? You can create great animations in just a few lines of code.
In Cocos2D this will also works great but is much more work and more complicated.
If so, is there any tutorial? For my game I really need this feature.
Regards,
M.J.
Comments
In fact GiderosStudio also comes with GiderosTexturePacker an integrated app that allows to create textures. It also works with textures created using TexturePacker from Andreas L.
Have a look at the code in that example.
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
Apart from your question, all documents under Academy are worth printing out, and reading around when you have time and silence.
Regards,
Marc
Graphics 3 is one of the pages of examples in the Gideros Studio IDE, where there is a Texture Pack example.
HTH
Cheers
evs
Thanks again,
M.J.
I am still searching for the ultimate game designing tool.
I tried to do some animation with Gideros and I must say that it is quiet complicated. You will need a separate sprite sheet (like in all the developer tools), a txt file containing the data and a separate Lua class file. Why not in a way like for example RapaNui/MOAI :
--setting up a sequence
function onEnd1()
char:play("shorttolong")
end
function onEnd2()
char:play("longtoshort")
end
--Animation of spritesheet images in sequences
--createAnim(file, width, height, x, y, scale_x, scale_y)
test = RNFactory.createAnim("spriteSheet.png", 240, 240, 140, 640 - 420, 0.5, 0.5)
--newSequence(name,frameOrder,speed,repeatTimes,onStopFunction)
test:newSequence("shorttolong", { 7, 6, 5, 4, 3, 2, 1 }, 1, 100, onEnd2)
test:newSequence("longtoshort", { 1, 2, 3, 5, 5, 6, 7 }, 1, 100, onEnd1)
test:play("shorttolong")
Or in Corona even simpler:
--A sprite sheet
local data = require("spriteSheet").getSpriteSheetData();
local test_sheet = sprite.newSpriteSheetFromData("spriteSheet.png", data)
local spriteSet = sprite.newSpriteSet(test_sheet, 1, 7)
sprite.add( spriteSet, "reus", 1, 7, 2000, 0 ) -- play 7 frames every 2000 ms
local instance = sprite.newSprite(spriteSet)
instance.x = 130
instance.y = 520
instance:prepare("test")
instance:play()
And Guideros:
In main.lua:
stage:addChild(AnimatedSprite.new())
In test.lua
AnimatedSprite = Core.class(Sprite)
function AnimatedSprite:init()
local pack = TexturePack.new("test.txt", test.png")
self.anim =
{
Bitmap.new(pack:getTextureRegion("test_240px_Retina_1_25g.png")),
Bitmap.new(pack:getTextureRegion("test_240px_Retina_2_25g.png")),
Bitmap.new(pack:getTextureRegion("test_240px_Retina_3_25g.png")),
Bitmap.new(pack:getTextureRegion("test_240px_Retina_4_25g.png")),
Bitmap.new(pack:getTextureRegion("test_240px_Retina_5_25g.png")),
Bitmap.new(pack:getTextureRegion("test_240px_Retina_6_25g.png")),
Bitmap.new(pack:getTextureRegion("test_240px_Retina_7_25g.png")),
}
self.frame = 1
self:addChild(self.anim[1])
self.nframes = #self.anim -- WHAT DOES THIS MEAN?
self.subframe = 0
self:addEventListener(Event.ENTER_FRAME, self.onEnterFrame, self)
self:setX(10)
self:setY(400)
end
function AnimatedSprite:onEnterFrame()
self.subframe = self.subframe + 1
if self.subframe > 4 then
self:removeChild(self.anim[self.frame])
self.frame = self.frame + 1
if self.frame > self.nframes then
self.frame = 1
end
self:addChild(self.anim[self.frame])
self.subframe = 0
end
end
Hope that this will become simpler because I am really a great fan of Gideros.
Regards,
Marc
evs
Marc
using a # gives the count of objects in the table (in the above line the number of frames or bitmaps)
for example:
cheers
evs
Do you have a game creation I can check? Your example works great. Do you know how I simply can change the framerate. I looked through the docs and tried to use the Event.COMPLETE event but that is not the right way. Now the animation is a little bit to fast.
Regards,
Marc
I haven't released anything yet, just building up my arsenal of routines
Here's a way to animate with the timer (uses the same assets as before)
cheers
evs
Marc