Can someone get me headed in the right direction with regard to animation of a character.
I’ve been learning and working on the beginnings of a game. I wrote a bunch of code for an image object using a touch event listener (to play sound when it begins moving, rotate left and right for single and double tap, etc.).
First (broader) Question:
Now I want to start adding some animation, such as the image changing to a different one as soon as the object “launches” (is dragged), and later when it gets near another type of image object. Apparently the movieclip library is what I should use. However, it seems to have it’s own drag method. So now … do I rewrite everything, calling functions from within object:setDrag( ) ?!
Second Question:
So I started experimenting with the movieclip functions, and got the image to change when the user drags. However it changes back to the first image as soon as it’s clicked on again. I’m sure that’s easily solvable, but before I start adding a bunch of code…
(First question again): Do I now just start adding functions within the movie drag event for the gameplay, replacing all my touch event code, such as for sound and image changes, responses?
Tet code:
local movieclip = require "movieclip"
myAnim = movieclip.newAnim{ "sitting.png", "flying.png" }
myAnim.x=100
myAnim.y=100
function changeTo()
onPress=myAnim:nextFrame()
end
-- Make sprite draggable
myAnim:setDrag{
drag=true,
onPress=changeTo
--- add more actions here
}
Third Question: I notice the movieclip library has it’s own event listener - I notice I don’t have to use
Runtime:addEventListener(“touch”, whatever)? However, I don’t want to have to mess with customizing the movieclip library to add single/double tap rotation, etc.
Sorry if my first question is too general. I just don’t want to waste a lot of time reinventing the wheel …
Thanks!
Eric [import]uid: 128346 topic_id: 24174 reply_id: 324174[/import]
[import]uid: 52491 topic_id: 24174 reply_id: 97656[/import]
That doesn’t make it fact, though, I just find them easier to work with efficiently.