newSprite questions

I’ve been trying to get an animated sprite to work and had to luck on the literature I found from Corona… I was just always doing something wrong and couldn’t figure it out. I found a tutorial that got me here… This code works but I need to be able to adjust the frame rate or frame change speed. How could I accomplish this?

[lua]require “sprite”

local rocketSheet = sprite.newSpriteSheet(“rocketSprite.png”, 92, 51)

local spriteSet = sprite.newSpriteSet(rocketSheet, 1,2)

local instance = sprite.newSprite(spriteSet)
instance.x = display.contentWidth / 2
instance.y = display.contentHeight / 2

instance:play()
[import]uid: 20272 topic_id: 35203 reply_id: 335203[/import]

This is the old sprite method and it’s now deprecated. The new method is a bit different. Here’s a big blog post about it.

Simple form:

[code] – [1] make the sheet
local options = {
width = 8, – per frame
height = 8, – there is a different method to use here if frames have different sizes
numFrames = 5
}
local rocketSheet = graphics.newImageSheet(“rocketSprite.png”, options)

– [2] make the frame sequence(s)
local rocketFrames = {}
rocketFrames[1] = { name=“runleft”, frames={1,2,3,4,5}, time=300}

– [3] make the sprite(s)
local rocketCar = display.newSprite(rocketSheet,rocketFrames)
rocketCar:setSequence(“runleft”)
rocketCar:play()[/code] [import]uid: 41884 topic_id: 35203 reply_id: 139953[/import]

Alright I got it working with the new code… Appreciate the help! [import]uid: 20272 topic_id: 35203 reply_id: 139967[/import]

This is the old sprite method and it’s now deprecated. The new method is a bit different. Here’s a big blog post about it.

Simple form:

[code] – [1] make the sheet
local options = {
width = 8, – per frame
height = 8, – there is a different method to use here if frames have different sizes
numFrames = 5
}
local rocketSheet = graphics.newImageSheet(“rocketSprite.png”, options)

– [2] make the frame sequence(s)
local rocketFrames = {}
rocketFrames[1] = { name=“runleft”, frames={1,2,3,4,5}, time=300}

– [3] make the sprite(s)
local rocketCar = display.newSprite(rocketSheet,rocketFrames)
rocketCar:setSequence(“runleft”)
rocketCar:play()[/code] [import]uid: 41884 topic_id: 35203 reply_id: 139953[/import]

Alright I got it working with the new code… Appreciate the help! [import]uid: 20272 topic_id: 35203 reply_id: 139967[/import]