Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by dr0w

I am currently implementing a side scroller that requires the map to zoom in and out and am doing so by using ig.system.context. However, when compiling for iPhone 4 with Ejecta, after a certain number of zooms, Xcode throws

2012-12-04 21:07:54.584 Ejecta[8347:707] Warning: EJ_CANVAS_STATE_STACK_SIZE (16) reached

...and the game hangs.

What I was wondering was whether there is a way to query what the current stack size is in my main update so that I can prevent it from zooming too many times.

1 decade ago by dominic

You probably .save() the state more often than you .restore() it. Each ctx.save() needs a corresponding ctx.restore() or you will blow the stack sooner or later.

Zooming to an arbitrary level shouldn't need more than one stack level, anyway. Unless I misunderstood what you're doing.
draw: function() {
	ig.system.context.save();
	ig.system.context.scale( this.zoomFactor, this.zoomFactor );
	
	this.parent();
	
	ig.system.context.restore(); // <- important
}

If you really need a bigger state stack, you can modify the EJ_CANVAS_STATE_STACK_SIZE at the top of Classes/Ejecta/EJCanvas/EJCanvasContext.h.
Page 1 of 1
« first « previous next › last »