To give you an idea, it's a really simple navigation map of a city with some buildings/locations and a character sprite, representing the main character, acting as a cursor. The player would be able to click on a building and the sprite would move (changing from an idle image to animated image of the character walking) to that location.
Now this in my head sounded fairly simple to do and I've already implemented a prototype, but I've encountered a problem: the movement animation isn't showing.
For now I have two sets of images for the character, one idle image and one of the character moving, and I'm using screen variables to change the images.
Here's my code:
Code: Select all
#Image to use when idle (not moving)
image hero_idle:
"Hero_idle_1.png"
#Image to use when character is moving
image hero_move:
"Hero_move_1.png"
pause .5
"Hero_move_2.png"
pause .5
repeat
# A simple transform to update the chars position
transform nav_pos(s,x,y):
linear s xalign x yalign y
#The navigation screen
screen nav_map():
#Screen variables for character speed, x, y, and the image itself
default hn_s = .2
default hn_x = .5
default hn_y = .5
default hero_sprite = 'hero_idle'
#Add the image to the screen
add hero_sprite at nav_pos(hn_s, hn_x, hn_y)
#A test button that moves the character to the left
frame:
xalign .4
yalign .8
id "left_button"
textbutton "Left":
action [
SetScreenVariable('hero_sprite', 'hero_move'),
SetScreenVariable('hn_x', hn_x - .4),
SetScreenVariable('hero_sprite', 'hero_idle')
]
#Same as previous button, but for the other direction
frame:
xalign .6
yalign .8
id "right_button"
textbutton "Right":
action [
SetScreenVariable('hero_sprite', 'hero_move'),
SetScreenVariable('hn_x', hn_x + .4),
SetScreenVariable('hero_sprite', 'hero_idle')
]