Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
A movieclip problem / question — Gideros Forum

A movieclip problem / question

NinjadoodleNinjadoodle Member
edited November 2017 in General questions
Hi guys

I have a movie clip and I need to insert 3 stop actions. On each of the stop actions, I need to use a timer to wait one second before resuming play.

I can get this working with 1 stop action, by telling the movie clip exactly which frame to resume play on, but because I can't check what frame the movieclip is on, I can't get it to work with more than 1 stop action.

The other issue I'm having is that, I've got a touch event listener on the mc, but I only want it to respond when the mc is between a certain frame range.

- Any way to check the frame I'm on?
- Can I pause and play / where left off

Any other ideas?

Thanks heaps in advance :)

Comments

  • NinjadoodleNinjadoodle Member
    edited November 2017
    @pie - thanks heaps for the tip!

    I can't however get it to work ...
    self.invader1.mc:addEventListener(Event.COMPLETE, function()
            Timer.delayedCall(500, function () print(self.invader1.mc:getFrame()) end)
    end, self.invader1.mc)
    *** EDIT ***

    I might be using an old version of Gideros ... I'll try to update :)
  • Ah, I'm sorry I just trusted @totebo :) never used that...
  • @pie - I think I'm using an old Gideros version, trying to update now. I'll let you know if it works - thanks heaps for the help btw :)
  • Just updated, but nope, can't get it to work ...

    self.invader1.mc:gotoAndPlay(1)
    self.invader1.mc:getFrame()

    stage05.lua:38: attempt to call method 'getFrame' (a nil value)
  • Oh wait ... I forgot to update the player!
  • Alright, so I've updated the player and here is what happens ...

    When I test locally it works fine :)

    When I try testing through the android player, I get this ...

    stage05.lua:37: attempt to call method 'getFrame' (a nil value)
    stack traceback:
    stage05.lua:37: in function 'onBegin'
    setupStage.lua:45: in function

    Likes: pie

    +1 -1 (+1 / -0 )Share on Facebook
  • Yup all done but doesn’t work :(
  • I tested it the other day and it returned the frame! Very strange.

    Likes: Ninjadoodle

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • hgy29hgy29 Maintainer
    Can you double check your android player version ? If it works locally then it should work with android player too, the code is common to all platforms.

    Likes: Ninjadoodle

    +1 -1 (+1 / -0 )Share on Facebook
  • Hi @totebo - even on the android player?

    For me it only return the frame in the desktop player.
  • When you call mc:play(), does it start playing from the start or where it was when you call mc:stop()?

    Likes: Ninjadoodle

    +1 -1 (+1 / -0 )Share on Facebook
  • @ninjadoodle, I think I tried it on the desktop player only
    Out and about, but will try when I'm back in front of a computer.

    Likes: Ninjadoodle

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • antixantix Member
    edited November 2017
    @Ninjadoodle, here is an example using Gideros 2017.11.1 which plays coin animation. When you touch the screen it will pause the playback at the current frame and after one second the playback will resume where it left off.

    This example is fully working on Windows player, Android player, and as an installed APK on my Nexus 4.

    I'm not sure why your code does not work. If you want me to have a look try to catch me in Skype :bz
    zip
    zip
    MovieClip 2.zip
    29K

    Likes: Ninjadoodle

    +1 -1 (+1 / -0 )Share on Facebook
  • Hi @antix - thanks heaps for the code, really appreciate your time :)

    I'm still having the same issue with the android player - can I ask you what your android player says in the top left corner (mine says 2016.6).

    I have a feeling that it's an old player, even though I've tried reinstalling the new one twice.
  • It works! My stupid fault after all - for some reason I had two sets of players in my installed app folder and I was copying an old one (must have been left from a previous install).

    This time, everything works fine ... the only thing that will not work for me is setting a 'stop action', mid animation and then trying to resume using mc:play()

    Likes: totebo, antix

    +1 -1 (+2 / -0 )Share on Facebook
  • If you are updating your clip every frame and during that update you are using getFrame() to get which frame is currently playing.. then when the frame is the correct one, you can pause the animation with stop() and do like my example, set a paused flag and then countdown a timer, which on reaching 1, resumes the playback.

    I hope that makes sense.

    Any code you can share where we could see what is going wrong would be good :)

    Likes: Ninjadoodle

    +1 -1 (+1 / -0 )Share on Facebook
  • Glad you got it working, just tested it on an Android player and it was fine.

    If you use setStopAction( 10 ) you need to clear it before using play() for it to continue. If you don't clear it, the stop action will trigger again when frame 10 has finished playing, and the playhead won't move to the next frame.



    Likes: Ninjadoodle

    My Gideros games: www.totebo.com
    +1 -1 (+1 / -0 )Share on Facebook
  • @totebo that's true but just using stop() causes it to basically pause on the current frame and then you just use play() to resume playing.

    Likes: Ninjadoodle

    +1 -1 (+1 / -0 )Share on Facebook
  • NinjadoodleNinjadoodle Member
    edited November 2017
    @totebo - I'm glad it's working too, I was starting to pull my hair out over it lol. Thanks for the tips on the gotoActions. I got my code working now for what I need, so I'll look into it a bit more, next time I'm using it.

    @antix - One question about the sample code you've attached. Whats the benefit of using Delta Time and OS timer, instead of let's say Timer.delayedCall (which is what I'm using)?

    Thanks :)
  • @Ninjadoodle, when you have a coupe of timers that's cool but when you start getting many game objects and have to have heaps of timers.. that starts to affect performance.

    deltaTime based timers are IMHO more efficient (somebody please correct me if I'm wrong) :)

    Likes: Ninjadoodle

    +1 -1 (+1 / -0 )Share on Facebook
  • totebototebo Member
    edited November 2017
    When it comes to ENTER_FRAME vs. Timer there are a couple of other benefits using ENTER_FRAME;

    1. If you have just one gameloop using ENTER_FRAME (that is used for all animation etc) you can easily pause the game when needed. This is very useful.

    2. If you use only ENTER_FRAME you can be sure everything is updated at the same time. Timer is not precise and can skip frames or two could happen within one frame. In practice this can lead to issues where tweens lag behind or skip frames, for example. Timers are great, but don't rely on them to manipulate graphics.

    Likes: antix, Ninjadoodle

    My Gideros games: www.totebo.com
    +1 -1 (+2 / -0 )Share on Facebook
  • @antix and @totebo - thanks for the tips guys, I appreciate it :) I'm going to convert my timer to an ENTER_FRAME to avoid any sync issues :)
Sign In or Register to comment.