Exemplo n.º 1
0
KrCollisionMap* KrSpriteResource::GetCollisionMap( KrImage* state/*, int window*/ )
{
	GLASSERT( state && state->ToSprite() );
	KrSprite* sprite = state->ToSprite();
	GLASSERT( sprite->SpriteResource() == this );

	if ( state->XScale( /*window*/ ) != 1 || state->YScale( /*window*/ ) != 1 )
	{
		if ( !IsScaleCached( state->CompositeXForm( /*window*/ ).xScale,
							 state->CompositeXForm( /*window*/ ).yScale ) )
		{
			// For sprites, only cached scales can be used!
			/*#ifdef DEBUG
			GLOUTPUT( "ERROR: Collision only allowed with cahed sprites!\n" );
			GLOUTPUT( "SpriteResource '%s' for Action '%s' Frame %d scale %f, %f\n",
					  ResourceName().c_str(),
					  sprite->GetAction()->Name().c_str(),
					  sprite->Frame(),
					  state->CompositeXForm( window ).xScale.ToDouble(),
					  state->CompositeXForm( window ).xScale.ToDouble() );
			#endif*/
			GLASSERT( 0 );
			return 0;
		}
	}
	KrAction* action = sprite->GetAction();
	return action->GetCollisionMap( state->CompositeXForm( /*window*/ ).xScale,
									state->CompositeXForm( /*window*/ ).yScale,
									sprite->Frame() );
}
Exemplo n.º 2
0
PyObject *
_wrap_sprite_get_action (PyObject *self, PyObject *args)
{
	   PyObject *py_r;
	   
	   if (!PyArg_ParseTuple (args, "O:get_action", &py_r)) return NULL;
	   GLASSERT (py_r && py_r != Py_None);
	   
	   KrSprite *r = AS_PTR (KrSprite, py_r);
	   GLASSERT (r);
	   
	   KrAction *action = r->GetAction();
	   GLASSERT (action);
	   
	   return PyCObject_FromVoidPtr (action, NULL);
}