User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: Can someone explain this "create object" behavior to me?

  1. #1
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can someone explain this "create object" behavior to me?

    I made a sample to test object creation and instancing. Something really confuses me:

    I have a Game with 5 Balls. I have to following condition:

    + By pressing Button 1
    - create "Bullet" @ "Ball"
    - set Bullet color to red
    - scale Bullet to 0.5

    --> So when I press the Button, Every Ball creates a Bullet but only one bullet changes to red and scales to 0.5. The rest doesn't get attributes applied. I get that, it has to do with the "action loop"...

    Now if I take the same condition but I create TWO Bullets instead of just one, then every Bullet from every ball gets red and becomes resized.

    1. Can someone explain this to me?
    2. Is there some way to "cheat" the system so I can have this second behavior when I just want to create ONE bullet? (if possible without fastloops?)

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,365
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    To answer your second question, you can do this by setting the actions in another event.

    Below the event that creates the objects, have this event:

    * Bullet is in playarea
    + Only one action when event loops
    - set Bullet color to red
    - scale Bullet to 0.5

  3. #3
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Popcorn View Post
    To answer your second question, you can do this by setting the actions in another event.
    * Bullet is in playarea
    + Only one action when event loops
    - set Bullet color to red
    - scale Bullet to 0.5
    Thanks popcorn. Your idea works in my example.
    But what if I want the bullets to get a value from the ball object? Like this:

    + By pressing Button 1
    - create "Bullet" @ "Ball"
    - set Bullet value(A) to Ball Value(A)

    now it is important that I have a reference to the ball object.

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    Popcorn's Avatar
    Join Date
    Jun 2006
    Location
    Norway, Bergen
    Posts
    2,365
    Mentioned
    13 Post(s)
    Tagged
    0 Thread(s)
    I don't think MMF is designed to do this without running a fastloop. You would need to run a fastloop (or a foreach loop) when you create the bullets, and then assign the values for each bullet.

  5. #5
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just do it in two events

    -Button pressed
    Create object "Kitten"

    -Button pressed
    Set Scale( "Kitten" ) to 1337

  6. #6
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Jacob! But like I said, object1 needs to created relativ to an other object. And it should be possible to transfer a value from object1 to Object2.

    + By pressing Button 1
    - create "Bullet" @ "Ball"
    - set Bullet value(A) to Ball Value(A)


    I didn't have time to test it yet (at work) but will this be a solution to stay away from SpreadValues?

    + By pressing Button 1
    - set Ball Value Z = 1 (if you have multiple Balls, will all be affected?)

    + If Ball Value Z = 1 (Will it test every singel Ball and run this event for all of them?)
    - create "Bullet" @ "Ball"
    - set Bullet color to red
    - scale Bullet to 0.5

  7. #7
    Clicker Multimedia Fusion 2 Developer
    Blue66's Avatar
    Join Date
    Jan 2008
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MMF2 has a weird logic sometimes and it costs a lot of frustration for me. Maybe I'm just too dumb to use it. Anyways, as always wenn MMF2 just doesn't get what I want to do with it, I have tons of weird workarounds to get it to do what I want.

    For this I would suggest making an "overseer" object that is hidden outside the frame and use its alterable values. Like this:

    +always
    -set Overseer alterable value to 0

    +some event
    -create ShootObject at position of BallThing
    -set Overseer alterable value to alterable value of BallThing

    +some other event
    -set ShootObject alterable value to alterable value of Overseer

    If that is not enough for you, try the "ForEachObject" extension. It helped me out big time in some tough times with MMF2

  8. #8
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)
    Morbus Crohn: If each of the objects shooting could have unique values to transfer to their bullets, then you would need to use a loop to create them. In the long run, it will be more reliable and shouldn't cause you issues unless you have hundreds of objects each shooting lots of bullets all the time. You would use something like this:

    (fastloop method)
    +(Condition that causes any object to shoot a bullet)
    -Spread value 0 in AltVal A(Shooter Obj)

    +(Condition that causes any object to shoot a bullet)
    -Start loop "Shoot" Number of (Shooter Obj) times

    +On loop ("Shoot")
    +AltVal A(Shoot Obj) = LoopIndex ("Shoot")
    -Create "Bullet" at (Shooter Obj)
    -Set (property) of Bullet to AltVar A (Shooter Obj)

    Hope that helps,

    Mobichan

  9. #9
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Nov 2011
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your replies! mobichan, your solution works perfect and it is exactly what I want. My only problem is that I am afraid that my code gets too complicated and I still don't trust fastloops performance wise. (I am using the ios exporter).
    What do you think of my alternative method? Will this work?

    + By pressing Button 1
    - set Ball Value Z = 1 (if you have multiple Balls, will all be affected?)

    + If Ball Value Z = 1 (Will it test every singel Ball and run this event for all of them?)
    - create "Bullet" @ "Ball"
    - set Bullet color to red
    - scale Bullet to 0.5

  10. #10
    Clicker Fusion 2.5

    Join Date
    Mar 2007
    Posts
    495
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I'm using just that method (Mobichan's) and it seems very fast. (at least with HWA it is).

    I don't think your suggestion will work because in the first event - all your objects would be affected.
    You can test to see whether the object has just been created by testing to see if a value is default (i.e.: 0).
    You then set it to 1 and carry out your actions on those objects in that event.

    Problem is that it has to page and test all those objects all the time. If you're creating vapour trails or particles and there's 1,000s of them, then that's not anywhere near efficient.
    With Mobichan's method, there's no real test on the object the actions are just applied to that object when it is created individually in its loop.
    It seems to be very efficient.

    By changing methods, the performance of my app has pretty much rocketed.
    2400 objects; all interacting on an Athlon 64 2GHz

Page 1 of 2 1 2 LastLast

Similar Threads

  1. all my Objects have Dissapeared? I cant "Create a new Object"
    By Keehan in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 16th January 2013, 01:40 PM
  2. Why does "Create Object" make multiples instead of one item
    By rubes in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 6th May 2012, 12:01 AM
  3. Issues with "Clickteam Movement Controller" and "Runtime" Object
    By jimmyorpheus in forum iOS Export Module Version 2.0
    Replies: 1
    Last Post: 29th November 2011, 08:10 AM
  4. How to tidy up the "Create new object" dialogue?
    By RayRayTea in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 5th August 2011, 05:06 PM
  5. "Create Object" crash
    By blutark1 in forum Multimedia Fusion 2 - Technical Support
    Replies: 4
    Last Post: 3rd November 2010, 11:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •