Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075929 Posts in 44152 Topics- by 36119 Members - Latest Member: Royalhandstudios

December 29, 2014, 04:03:19 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Switch Sprite on Specific Frame?
Pages: [1]
Print
Author Topic: Switch Sprite on Specific Frame?  (Read 535 times)
jddg5wa
Level 1
*



View Profile
« on: September 18, 2013, 04:23:00 PM »

So I have a code that doesn't seem to run. It's set in a key press even and it does nothing when the key is pressed. It worked before I added the "if image_index=0". I have a similar keypress event that has an if statement before it that works.

The animation runs at .75 speed and I was wondering if that is to fast for it to notice when it is at frame 0. I can usually get things when it doesn't work how I want but this doesn't work at all and I have no idea how to do it any other way. Any suggestions? Thanks!

Code:
if image_index=0
    {
        //Active Landing Gear   
        sprite_index=Landing_Gear_Sp 
        image_speed=.5     
    }
Logged

\\\"Around here, however, we don\\\'t look back for very long. We keep moving forward, opening new doors, and doing new things, because we\\\'re curious and curiosity keeps leading us down new paths.\\\"      - Walt Disney
ink.inc
Guest
« Reply #1 on: September 18, 2013, 04:31:37 PM »

if you run in debug mode, you can check the variables for a specific instance (including image_index). if you look it up, you will see that image_index will (almost) never be exactly zero because image_index is not an integer; it increments by a value equal to image_speed/framerate every frame.

please give me more context w/r/t the code and i can help you further.
Logged
jddg5wa
Level 1
*



View Profile
« Reply #2 on: September 18, 2013, 04:50:46 PM »

That would make sense as to why I've been having trouble. Even noticed I've had trouble with other "if image_index=_" scripts. I saw what you mean about it not really exactly being zero. Even then it's never really a whole number if at all. I just changed the =0 to <1 and it seems to be working fine now. I hope it stays that way.

And thanks too, didn't realize I could see instance variables in debug mode.

« Last Edit: September 18, 2013, 06:32:05 PM by jddg5wa » Logged

\\\"Around here, however, we don\\\'t look back for very long. We keep moving forward, opening new doors, and doing new things, because we\\\'re curious and curiosity keeps leading us down new paths.\\\"      - Walt Disney
ink.inc
Guest
« Reply #3 on: September 18, 2013, 04:56:18 PM »

cool cool cool

if i may ask why are you trying to change animations when the image index is zero anyway? that would mean that the animation you're currently on hasn't even played.
Logged
@Alex@
Level 0
***


View Profile Email
« Reply #4 on: September 19, 2013, 07:06:57 AM »

Or the animation has begun to loop in which case the animation end event is better place to place the code unless image_speed < 0 since it doesn't trigger when going backward.

You can always round your image_index with floor, round and ceil or various bitwise operators.
Logged
jddg5wa
Level 1
*



View Profile
« Reply #5 on: September 23, 2013, 06:22:44 PM »

cool cool cool

if i may ask why are you trying to change animations when the image index is zero anyway? that would mean that the animation you're currently on hasn't even played.

Like Alex said the main animation is already looping. When you press a button another animation starts on frame 0 of the main animation. So I needed to have the main animation stop only on frame 0 so the other animation transitions smoothly.  
Logged

\\\"Around here, however, we don\\\'t look back for very long. We keep moving forward, opening new doors, and doing new things, because we\\\'re curious and curiosity keeps leading us down new paths.\\\"      - Walt Disney
Titanium
Level 0
**


View Profile Email
« Reply #6 on: September 27, 2013, 10:07:17 PM »

There's an event called Animation End under Other with Room Start, Game Start and the like.  I think this is the event you'll need.
Logged


Please Play My Games.
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic