Suggestion Issue: 2 minor additions to the engine.


Pages: 1

SadiQ

  • Level 5 Stencyler
October 05, 2018, 10:57:08 pm
Log viewer:
 -Whenever I have to deal with games that have a large number of scenes and I need to track where I end up after pressing some buttons, I find it pretty useless to get a message with the ID of the scene when switching scenes in the log viewer,  when I'm actually interested in the name of the scene. I've been using this switchScene() function in Engine.hx to get that name to show up:
Code: [Select]
public function switchScene(sceneID:Int, leave:Transition=null, enter:Transition=null)
{

if(isTransitioning())
{
// trace("Warning: Switching Scene while already switching. Ignoring.");
return;
}

var sceneName:String = "";
for(s in GameModel.get().scenes)
{
if(sceneID == s.ID)
{
sceneName = s.name;
}
}
trace("Switching to scene " + sceneID + " name = " + sceneName);

if(leave != null && leave.isComplete())
{
leave.reset();
}

if(leave == null || leave.duration == 0)
{
leave = new Transition(0);
}

if(enter == null || enter.duration == 0)
{
enter = new Transition(1);
}

this.leave = leave;
this.enter = enter;

if(!this.leave.isComplete())
{
this.leave.start();
}

sceneToEnter = sceneID;
}


Pausing a game:
 - It seems that in all the games I've seen, people used blocks that either stop all sounds, stop sound on a certain channel or set the volume to 0 whenever they pause the game and then they start back the sounds or set back the volume whenever the game has to resume.
 I simply pause all the sounds when the game pauses and I resume all sounds when the game unpauses in Engine.hx, but maybe it could be integrated in the pause/unpause blocks with the option to pause all sounds or not :
Code: [Select]
public function pause()
{
if(isTransitioning())
{
return;
}

paused = true;

if(!allActors.isEmpty())
{
for(actorID in allActors.keys())
{
var a = allActors.get(actorID);

if(a != null)
{
a.pause();
}
}
}

//NOTE: pause all sounds
for(index in 0...Script.CHANNELS)
{
Script.pauseSoundOnChannel(index);
}
invokeListeners2(whenPausedListeners, true);
}

public function unpause()
{
if (!paused) return;
paused = false;

if(!allActors.isEmpty())
{
for(actorID in allActors.keys())
{
var a = allActors.get(actorID);

if(a != null)
{
a.unpause();
}
}
}

//NOTE: unpause all sounds
for(index in 0...Script.CHANNELS)
{
Script.resumeSoundOnChannel(index);
}

invokeListeners2(whenPausedListeners, false);
}


Pages: 1

Details

  • Reported
    October 05, 2018, 10:57:08 pm
  • Updated
    October 05, 2018, 10:57:08 pm

  • View Status
    Public
  • Type
    Suggestion
  • Status
    New
  • Priority
    Normal
  • Version
    Stencyl 3.4, Stencyl 3.5
  • Fixed in
    (none)
  • Assigned to
    (none)
  • Category
    Engine

Tags