Advertisement Jump to content


This topic is now archived and is closed to further replies.

Roof Top Pew Wee

Clearing events working inside a class, but not outside.

This topic is 5340 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In my engine, I have a Sprite object, which as an event as follows: public event customFunction customFunctions; So my understanding that if I want to clear the customFunctions event and start fresh, I simply write customFunctions = null; Then += whatever I want. That works fine inside of the Sprite class, but if I try to set customFunctions outside of the Sprite class, I get a syntax error. And the event is public for sure, so that''s not the issue. C:\Projects\Entai\GameMain.cs(189): The event ''FRB.Sprite.customFunctions'' can only appear on the left hand side of += or -= I encased customFunctions = null inside a method in my SpriteClass, but why would I need to do that for it to work? This is for my particle creation/destruction, so any bit of speed is needed. Any ideas? --Vic--

Share this post

Link to post
Share on other sites
IIRC, one of the main differences between events and delegates is that events are more protected, in that you can only set it inside the class. But don''t quote me on that.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!