Page 1 of 1

Moving an animated Sprite with arrowkeys

Posted: Mon Dec 30, 2013 8:44 pm
by Bobby666
Hello everyone! :)
First I know LiveCode a while and I've edited all of these tutorials : Learning to create Games (I can't poste any links sry)
So I would like to create a game with an animated Sprite which can be controlled with the arrow keys.
What I have to change on this code that the Player moves like Mario when he presses the arrow keys?
How can an animate a Sprite?
I hope you all know what I mean :)

I would be very thankful about any response :) Sorry for my bad english :)


on arrowkey x

if x is "right" then
set the right of the button "box" to the right of the button "box" + 10
if right of the button "box" > the right of the card "mycard" then
set the right of the button "box" to the right of the card "mycard"
end if
end if

if x is "left" then
set the left of the button "box" to the left of the button "box" - 10
if the left of the button "box" < the left of the card "mycard" then
set the left of the button "box" to the left of the card "mycard"
end if
end if

end arrowkey
(Its the code from the Tutorial Moving your Player)

Re: Moving an animated Sprite with arrowkeys

Posted: Tue Dec 31, 2013 3:22 am
by Newbie4
This might do it...
Import 2 images - one of Mario standing still and one that is an animated gif of him running. Change the 'skin' of the button "box" as you need to. (You do that by noting the ID of each image and setting the icon of the button to one ID or the other.

Normally use the one of him standing still. Then in your code where you move him, set it to the animated one of him running. As you exit the code, set it back to the one of him standing still again.

Is this what you were asking?

Re: Moving an animated Sprite with arrowkeys

Posted: Fri Jan 03, 2014 1:18 pm
by SparkOut
http://forums.runrev.com/phpBB2/viewtop ... 216#p47216

This thread (the link points directly to a sample stack with sprite movement, but please read the whole of it) may help

Re: Moving an animated Sprite with arrowkeys

Posted: Fri Jan 03, 2014 1:38 pm
by Klaus
I get -> You are not authorised to read this forum. :shock:

Re: Moving an animated Sprite with arrowkeys

Posted: Sat Jan 04, 2014 9:15 pm
by Bobby666
Yes that was it Newbie4 thank you very much:)
My question was vaguely expressed sry for that;)

I get : "You are not authorised to read this forum" too :?

Re: Moving an animated Sprite with arrowkeys

Posted: Sun Jan 05, 2014 10:53 am
by SparkOut
Hmm it was the Game Academy, anyway here's the content of that one post by JosepM
JosepM wrote:Hi,

Let's walk... a sample of movement based on your sprite handle... really cool! :)

But how to handle to create a tiled map? Imagine that in the spritesheet we have the terrain tiles, objects... and as the map is moving we need to update the tiles... copy n time the group that have referenciate the inside image?
Other case will be show objects form the spritesheet. For example show a sword or treasure...

Salut,
Josep M

Re: Moving an animated Sprite with arrowkeys

Posted: Wed Jan 08, 2014 4:34 am
by capellan
Hi Bobby,

This is the website that you wrote about:
https://sites.google.com/a/pgcps.org/livecode/
Bobby666 wrote: So I would like to create a game with an animated Sprite which can be controlled with the arrow keys.
What I have to change on this code that the Player moves like Mario when he presses the arrow keys?
How can an animate a Sprite?
Check this stack:
http://revonline2.runrev.com/stack/359/ ... -Game-Test

and this one, published recently:
https://dl.dropboxusercontent.com/u/383 ... 2.livecode

This stack displays:

1) an animated gif inside a background group
with the Dynamic Layer property set.
Control the Dove position using the keyboard:
QWE
A S
ZXC

2) a 20 cards flip animation that plays
when you press the mouse button
inside the photo or stack background.

In this version, you could use sliders to control the speed
and movement step of the animated gif.

Al