Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Spritesheet counting and controlling problems
Started by le_salvagnini May 06 2019 08:14 PM

No replies to this topic
sprite frames animations controlling sprites sprite frame counting
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

le_salvagnini

[GLOBAL: userInfoPane.html]
le_salvagnini
  • Observer

  • 20 posts
  • Corona SDK

Friends, I´m having a small problem here

I´m making an app to show moon phases. 

There are 8 images of moon inside a spritesheet, but I´m struggling to change the images according to the moon.

I need to link a moon cycle variable to the sprite sheet, so it will change the image of the moon at aproximately every 3 days. But since spritesheets seems to be a closed method, how can i pass my conditions externaly to increment sprite count?

Are there any way to do that or shall i use a sequence of images instead of a spritesheet?

Thank you for any help!

 

Bellow a piece of my code:

...mooncycle calculation code...

M = Mooncycle variable --(between 0 and 3 would be new moon, between 3.1 and six crescent moon...and
goes on until it repeats again)

--Starting graphical block
background = display.newImageRect("MoonBack.png",320,480)
background.x = display.contentCenterX
background.y = display.contentCenterY
cabecalho = display.newText( "Moon Phases", 160, 5 , native.systemFontBold , 20 )
cabecalho:setFillColor(0, 0.5, 0.8)

--building spritesheet

local sheetData = {
width=160,
height=203,
numFrames=8,
sheetContentWidth=1280,
sheetContentHeight=203
}
local FaseMoon = graphics.newImageSheet("Lunarp.png", sheetData)
local sequenceData = {
{name="FasesLua",
start=1,
count=8,
loopCount=0,
loopDirection="forward"
}
}
local animation = display.newSprite(FaseMoon,sequenceData)
animation.x=display.contentWidth/2
animation.y=display.contentWidth/2.3

I can see the first frame of my spritesheet, but how can i increment the frame counting according to the lunar cycle?

Thanks !

 




[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: sprite, frames, animations, controlling sprites, sprite frame counting