Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > General > Best Practices

Reply
 
Thread Tools Rate Thread Display Modes
Old 10-18-2007, 01:47 PM   #1
kribba
Registered User
 
Join Date: Apr 2007
Posts: 27
Question MVC and complex objects

A question about using the MVC pattern. As far as i understand it an application should have one view, one controller and one model. And different examples i have looked at have implemented this smoothly and easily.

But when creating games, it seems that the objects get more complex. Say for example that there are different bugs flying around on the screen and the user should try and click on some and avoid some. The view consists of the graphics of the bugs, animation, and user input listeners. How will the controller work?

Should every bug have it's own controller? Or should every click be funneled into one controller class that decides what should happen?

Hope somebody has an answer
kribba is offline   Reply With Quote
Old 10-21-2007, 04:57 AM   #2
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

You can totally have more than 1 view. That's the cool thing about MVC. And each view could have its own controller or they could share.

In your case, each bug could be a view.
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Old 10-22-2007, 02:10 PM   #3
kribba
Registered User
 
Join Date: Apr 2007
Posts: 27
Default

thanx
Guess everything depends on what is smoothest to work with later on.

Also wouldn't having just one controller that handles everything break the idea of having encapsulated objects too? But at the same time it feels abit over the top to have one view, controller and model for everything on the screen
kribba is offline   Reply With Quote
Old 11-07-2007, 09:17 PM   #4
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
Default

I don't think so. I think it is usually 1 controller per 1 type of view.
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman
Flash Gordon is offline   Reply With Quote
Old 11-08-2007, 01:28 PM   #5
jsebrech
Joeri Sebrechts
 
Join Date: Apr 2005
Location: Antwerp, Belgium
Posts: 1,462
Default

For example, in a drawing program your menu/toolbox is a controller, all your image windows are views, and the actual data for the images are the models. Multiple views can exist for the same model (image), but in the end a single controller manages all the views / models.
jsebrech is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:27 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.