Moving an animated Sprite with arrowkeys

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Bobby666
Posts: 8
Joined: Mon Dec 30, 2013 6:59 pm

Moving an animated Sprite with arrowkeys

Post by Bobby666 » Mon Dec 30, 2013 8:44 pm

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)

Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 332
Joined: Sun Apr 15, 2012 1:17 am
Contact:

Re: Moving an animated Sprite with arrowkeys

Post by Newbie4 » Tue Dec 31, 2013 3:22 am

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?
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: Moving an animated Sprite with arrowkeys

Post by SparkOut » Fri Jan 03, 2014 1:18 pm

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

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Moving an animated Sprite with arrowkeys

Post by Klaus » Fri Jan 03, 2014 1:38 pm

I get -> You are not authorised to read this forum. :shock:

Bobby666
Posts: 8
Joined: Mon Dec 30, 2013 6:59 pm

Re: Moving an animated Sprite with arrowkeys

Post by Bobby666 » Sat Jan 04, 2014 9:15 pm

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 :?

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: Moving an animated Sprite with arrowkeys

Post by SparkOut » Sun Jan 05, 2014 10:53 am

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
Attachments
spritesexample2.livecode.zip
Stack provided by JosepM
(168.09 KiB) Downloaded 488 times

capellan
Posts: 654
Joined: Wed Aug 15, 2007 11:09 pm

Re: Moving an animated Sprite with arrowkeys

Post by capellan » Wed Jan 08, 2014 4:34 am

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

Post Reply