Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (517)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (578)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Changing animation-sequences of sprites  (Read 1067 times)
0 Members and 1 Guest are viewing this topic.
Offline Serethos

Junior Duke




Java games rock!


« Posted 2004-01-01 19:21:52 »

i have a little problem animating my sprites.
every game-object has several animator-objects
each storing a list of animation-frames for a
special sprite-movement. these animator-objects
can differ through nested classes, so theres one
for looping animation, one for one-shot and so
on.

now imaging my "main-class", my game-manager, which
schedules all game-objects. if an event occurs, e.g.
pressing a key, collision, whatever, the gamemanager
signals it to the game-objects so that they know,
they have to change the animation-strip.

for getting the correct animationstrip there is an
object which gets a reference of the actual animation.
so the animator-object actual_anim is set to shoot_anim,
walk_anim ... whatever shall be returnd for painting
over this dummy.

but now the big problem:
every call to an object that it shall change its animation
is done just in time. imaging a memory card game:
the first "animation" is a card, where you can only see the
deck-motive. after clicking, the card shall turn in a
little animation and then change its animation to a
"heart 8" (or whatever). my program would solve it this way:

animation references to 'hidden_card'
click on card recognized => animation is set to ??
either : open_card   -- now the turn-animation is missing
or     : turn_card   -- no i have to develope a system which
detects when the turn_animation has ended and through which
animation it sould be replaced (it hasnt to be always the same
in all cases)

the turn_animation has no clue, that is going to be replaced.
even if it did so it would not know, which animation should
follow...
Offline Jeff

JGO Coder




Got any cats?


« Reply #1 - Posted 2004-01-02 03:59:05 »

Im not exactly sure I understand what your problem is, but what you are describing sounds very much liek a finite state machine (FSM.)

An FSM has static states, and transitions defined that take it from onbe state to another. So your "Covered card" woudl be one state, your flip the transition, and the exposed card the next state.

How you code this is up to you but typically the way it is done is with an anim structure that throws an event when it hist its last frame. Do you start the transition anim, wait for it to throw the doen event and then doe the new-state animation.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

DarkCart (16 views)
2014-10-31 21:44:48

DarkCart (21 views)
2014-10-31 21:43:57

TehJavaDev (40 views)
2014-10-27 03:28:38

TehJavaDev (31 views)
2014-10-27 03:27:51

DarkCart (44 views)
2014-10-26 19:37:11

Luminem (27 views)
2014-10-26 10:17:50

Luminem (30 views)
2014-10-26 10:14:04

theagentd (36 views)
2014-10-25 15:46:29

Longarmx (64 views)
2014-10-17 03:59:02

Norakomi (62 views)
2014-10-16 15:22:06
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!