User Tag List

Results 1 to 4 of 4

Thread: Problem with internal flag and a counter

  1. #1
    Clicker Multimedia Fusion 2

    Join Date
    Dec 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Problem with internal flag and a counter

    EDIT: Just found the solution after posting. If I change the order of the operations described below everything works fine. But I don't know why that is, if you could tell me?

    Hi,
    I just started working with MF2 and I decided to create some very simple games just to try out some basic mechanics. One of these games doesn't work fine.

    This is what I want to do:
    There is one active object either facing up or down.
    When it's facing up you have to press ↓, its direction changes, add 1 to counter.
    When it's facing down you have to press ↑, its direction changes, add 1 to counter.
    When you press the wrong arrow key 1 is substracted from counter.

    This is what I did to achieve this with a single active object and a counter:

    + Internal flag 0 is on
    - set direction down

    + Internal flag 0 is off
    - set dircetion up

    + Internal Flag 0 is on
    + Upon pressing "Down Arrow"
    OR
    +Internal Flag 0 is off
    + Upon pressing "Up Arrow"
    - add 1 to Counter
    - toggle internal Flag 0

    + Internal Flag 0 is off
    + Upon pressing "Down Arrow"
    OR
    +Internal Flag 0 is on
    + Upon pressing "Up Arrow"
    - substract 1 to Counter

    The problem I noticed is that 1 is always substracted from the counter no matter which arrow key I press. I helped myself by simply add 2 to the counter when you press the right key but I would like to know what I did wrong in the first place?!

    I guess I am missing some very basic stuff here... I have to say I am new to programming so that might explain the stupidity of the question :)

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleSWF Export Module
    happygreenfrog's Avatar
    Join Date
    May 2011
    Location
    I.L.T.D.O.I.R (I.L.T.D.O.I.R's Location: The Dimension Of Infinite Recursion)
    Posts
    4,307
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    The problem was that events are done from order of top to bottom. The problem was that the second event was always triggering last, and both events always triggered. I'll explain why:

    Internal flag 0 was off when these events got reached (for the purpose of this explanation).

    + Internal Flag 0 is on
    + Upon pressing "Down Arrow"
    OR
    +Internal Flag 0 is off
    + Upon pressing "Up Arrow"
    - add 1 to Counter
    - toggle internal Flag 0

    Up arrow was pressed, internal flag 0 was off (both of the needed conditions are now met), internal flag 0 gets turned on, 1 is added to the counter.

    + Internal Flag 0 is off
    + Upon pressing "Down Arrow"
    OR
    +Internal Flag 0 is on
    + Upon pressing "Up Arrow"
    - substract 1 to Counter

    Internal flag 0 is on, up arrow was pressed (both of the needed conditions are now met), so now 1 is subtracted from the counter.

    It can be a little confusing to new-comers, so don't worry about it. I used to be a little confused about that sort of thing myself (and, sometimes, I find a bug in one of my games that is because the events weren't in the right order).

    By the way, welcome to the forums! In the future, you should put any threads about issues you have been having with programming in MMF2 or issues with MMF2 itself here:
    http://community.clickteam.com/forums/190-Multimedia-Fusion-2-Technical-Support

    This sub-forum (the one you posted in) is for General Discussion of Click Jam. It is a little confusing right now, but Clickteam is going to be re-organizing the forums soon, so, somewhat soon, you can expect things to get a little less confusing.

  3. #3
    Clicker Multimedia Fusion 2

    Join Date
    Dec 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you so much, you helped me out a lot.
    still, it's confusing me a little bit but I totally get your explanation and how mf works makes more sense to me now

  4. #4
    Forum Moderator Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleMac Export Module
    AndyH's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,445
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I agree with all the problems you highlight about flags, but they do have their place and can be useful. A couple of examples:

    1) They are useful when used for local, short term testing. For example if you want to simulate IF ... ELSE ... scenarios.
    2) They are useful when you need to identify a group of instances, and when you want to be able to toggle membership of those instances (although you could use alterable variables, flags are perfect for this).

    I'd hope we'd be able to drop flags in Fusion 3 but have them back as a data type. IE: All alterable values should allow us to choose the data type - General, String, Number, Decimal, Flag. Fusion could then choose the best way to store this data internally but we'd be able to work with data is a more structured way and be able to rename them, rather than be stuck with FLAG 0 to 31!

    BTW Snail, keep up with the videos, great to see them!
    Andy H @ ovine.net
    Awful Jokes - a new cartoon every day: http://awful.ovine.net/
    Ovine's games: http://www.ovine.net

Similar Threads

  1. Problem counter
    By rom in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 13th December 2012, 02:06 PM
  2. Counter problem in swf.
    By Earl in forum SWF/Flash Export Module Version 2.0
    Replies: 2
    Last Post: 24th March 2010, 08:10 AM
  3. Counter Problem
    By evilpantsmaster in forum The Games Factory 2 - Technical Support
    Replies: 4
    Last Post: 19th February 2008, 06:05 AM
  4. Counter problem in MMF
    By Rabagast in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 5th January 2008, 05:34 PM
  5. Set Internal Flag 2 Not Working?
    By Michael_Gummelt in forum Multimedia Fusion 2 - Technical Support
    Replies: 10
    Last Post: 1st August 2006, 10:57 PM

Tags for this Thread

Posting Permissions

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