0 Favourites

How do I use a function properly?

  • Hello,

    I have a problem using the function.

    For example I have:

    1. "if object1 overlaps with object 2"-> "object 1 set invisible"

    2. "if object1 overlaps with object 2"-> call functionx

    functionx->"object 1 set invisible"

    Case 1: works ok only object1 is invisible

    Case 2 : all objects are invisible.

    Real case scenarios are more complex but how shall I use the function properly in this case?

  • This video is useless .

    12:30 when he touches an enemy all enemies are stopped. He even says all the enemies.

    But NO you want when you touch an enemy only that enemy to stop.....

  • It is because he only used a single sprite. try making individual sprites for different objects. Here's a sample capx i made

    drive.google.com/file/d/0B6Kon9NMcnGGRmY3MkthaF9uQWs/view

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • I have a problem using the function.

    For example I have:

    . "if object1 overlaps with object 2"-> call functionx

    functionx->"object 1 set invisible"

    .. all objects are invisible.

    add object1 IID to function parameter...

    functionx->

    pick object1 by comparison IID=function parameter->object 1 set invisible

  • thanks. using object IID should solve the issue

  • In the event calling the function you have a condition that makes a list of all object1 that overlap object 2.

    In the function you have an action that picks all the object1, because there is no condition limiting the picklist.

    See it that way. You have always a 'picklist'. The picked objects stay in that list until you make another list.

    Pick conditions are filters to shorten the picklist, they make a list, they do not pick. Unless there is only one object in the resulting list. But even then you should not see it that way. The actions are the pickers, they pick objects from the pre-filterd list.

    The condition 'if object1 overlaps with object 2' makes a picklist of all instances of object1 and all instances of object2 who overlap. The action 'object 1 set invisible' takes all object1 instances in that picklist and makes them invisible.

    You could now think: no pick condition means no new picklist. And that is exactly where things go wrong.

    If you make a blanco event, followed by an action 'object 1 set invisible', then there was no filtering. The picklist contains all the objects. Every and each one. The action picks from that list all the object 1 instances.

    Tip: Make a variable object1picked and a variable object2picked. Set those in an action to object1.pickedcount and object2.pickedcount right after a pick condition. Monitor those variables to understand what is gooing on. Loop true them with object(loopindex).

  • Using object UID not IID is the correct answer to the problem

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)