Using actions on non scene objs

Hi!

I have created an object called soundclip, it manipulates everything related to AudioEngine,… For instance, a main menu bgm, the main menu bgm is in my case a soundclip that contains an ushort Id which is the returned value from AudioEngine::play2d()…

Until here works fine…

Now I want to create a function that progressively set the sound volume to desired target volume ( fade volume)… I can do this with ActionFloat reducing the volume progressively… Problem is that soundclip class is not an scene and inherits nothing.

I can include cocos2d.h into soundclip source file, that will make me use ActionFloat, but I cannot execute my action with runAction, since this function seems to be in a cocos abstract Scene class…

So my possibilities are:

  1. make soundclip inherits from cocos2d::Scene
  2. include Scene cocos class into the soundclip source file.
  3. do not implement soundclip, just use all my sound interfaces inside the scene class ( probably writing an abstract personalized superclass for all scenes)
  4. use Actions inside the scene and call set_volume() inside the ActonFloat…
  5. any other?

Thanks

Or just inherit from Node. You could inherit from Ref but I don’t think actions work on Ref.

You could always move around an off screen node and as part of that increment the volume.

Unless I don’t understand what you really want.

1 Like

i will try inheriting from Node, seems to be an elegant solution…
Thanks.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.