Need help with "Adding life through animation"

Hi! I need help. I’ve never programmed anything before, and I’m trying to follow your turorials. I read everywhere that everything is sooo easy but still a lot of instructions feels very cryptic, and usually assume that I know something about programming. This is very frustrating. I would much appretiate a little enlightment.

Right now I’m trying to figure out everything about the turorial ”Adding life through animation”,

In the first animation example I’m told to put in som properties to the tile I want to animate. I follow the instructions. And correctly the animation is very fast. But I’m confused because I only choose one tile, now it flips betweed different tiles seemingly at random. Is this a default setting. In the turorial I’m never told anyting about having an animation between specific tiles. Could anyone help me with this?

If I move on to the next animation I’m told to put in some new code. I paste it in. But I’m not told where to put it in. Before or after the physics code? I checked the examplecode and notices that you removed it entirely. Why? It’s not explained in the turorial. I tried keeping the physics code, moving it, and removing it. Nothing helped. Because when I run the simulator everything turns black. I try removing the code I just pasted in from the turorial and it works again, but with anymation 1. The code includes the name of the layer, and a made sure that the name was correct, not the one in the turorial since I picked a different one. I really need some help with this. What am I doing wrong? Is it something obvious? Am I supposed to change any of the other files? So far I’ve only changed the preferences of one tile, added the new code, changed the map name, and layername, tried to add, move and remove the physicscode. Nothing helps for the timebased animation. Please help. [import]uid: 32161 topic_id: 6397 reply_id: 306397[/import]

I’m sorry for a lot of misspelling. I tried to edit it, but it doesn’t work. [import]uid: 32161 topic_id: 6397 reply_id: 22146[/import]

Hey,

In the animation tutorial the property that tells Lime which tiles to use in the animation, beyond the one you add the properties to, is this one - frameCount - in the tutorial I have this set to 3 meaning the animation will include the current tile and the next 2, going from right to left.

The block of code simply loops through all the tiles on the layer until it finds the animated tile and then plays it.

You are right in that in the online tutorial I forgot to add in this bit of code that was in the downloaded version:

  
-- We first need to get access to the layer our tile is on, the name is specified in Tiled  
local layer = map:getTileLayer("Tile Layer 1")  
  
-- Make sure we actually have a layer  
if(layer) then  
  
 -- Get all the tiles on this layer  
 local tiles = layer.tiles  
  
 -- Make sure tiles is not nil  
 if(tiles) then  

So your entire code should look like this:

[code]

display.setStatusBar( display.HiddenStatusBar )

– Create a background colour just to make the map look a little nicer
local back = display.newRect(0, 0, display.contentWidth, display.contentHeight)
back:setFillColor(165, 210, 255)

– Load Lime
local lime = require(“lime”)

– Load your map
local map = lime.loadMap(“tutorial5.tmx”)

– Create the visual
local visual = lime.createVisual(map)

– We first need to get access to the layer our tile is on, the name is specified in Tiled
local layer = map:getTileLayer(“Tile Layer 1”)

– Make sure we actually have a layer
if(layer) then

– Get all the tiles on this layer
local tiles = layer.tiles

– Make sure tiles is not nil
if(tiles) then

– Loop through all our tiles on this layer
for i=1, #tiles, 1 do

– Check if the tile is animated (note the capitilisation)
if(tiles[i].IsAnimated) then

– Store off a copy of the tile
local tile = tiles[i]

– Check if the tile has a property named “animation1”, our sequence
if(tile.animation1) then

– Prepare it through the sprite
tile.sprite:prepare(“animation1”)

– Now finally play it
tile.sprite:play()
end
end
end
end
end

[/code] [import]uid: 5833 topic_id: 6397 reply_id: 22149[/import]

Ah, ok. Very interesting. Thank you Graham.

In the properties there are two animation sequences. What does this do? Isn’t there just one animation that loops around?

Going on:) I wrote a code that looked like this:

display.setStatusBar( display.HiddenStatusBar )

– Create a background colour just to make the map look a little nicer
local back = display.newRect(0, 0, display.contentWidth, display.contentHeight)
back:setFillColor(165, 210, 255)

– Load Lime
local lime = require(“lime”)

– Load your map
local map = lime.loadMap(“cool stuff.tmx”)

– Create our listener function
local onObject = function(object)
– Create an image using the properties of the object
display.newImage(object.image, object.x, object.y)
end

– Add our listener to our map linking it with the object type
map:addObjectListener(“PlayerSpawn”, onObject)

– Create the visual
local visual = lime.createVisual(map)

– We first need to get access to the layer our tile is on, the name is specified in Tiled
local layer = map:getTileLayer(“Foreground”)

– Build the physical
local physical = lime.buildPhysical(map)

With this everything works great. I even get the little guy to spawn and the brick flasches rapidly. But as soon as I paste in your code right before “Build the physical” everything turns black in the simulator. The preferences for the brick are:

Animation1 - frameCount=3,Time=1000
Animation2 - frameCount=3,Time=3000
IsAmimated
Sequences - Animation1,Animation2

Any insight? I really want the Timebased animation to work. But I also need to have the little guy spawn so I dont want to remove that code.

Thank you for your help. [import]uid: 32161 topic_id: 6397 reply_id: 22167[/import]

Hey, the multiple sequences can be used for multiple animation states, for instance a player might have “walk”, “run”, “jump”, “shoot” and “die”.

If you send your code to support@justaddli.me I will take a look at it as soon as I can. [import]uid: 5833 topic_id: 6397 reply_id: 22174[/import]

Thank you! I will email you the codes. [import]uid: 32161 topic_id: 6397 reply_id: 22198[/import]