nosemeocurrenada's Forum Posts

  • Created a plugin that creates new instances of other plugin using the runtime's documented function createInstance.

    While testing it, found that the "On created" condition was never triggered, to i took a look into the System CreateObject action. What I found was a little disturbing, checked out the Sprite's Spawn action and it did exactly the same disturbing thing:

    It sets some undocumented runtime flag to true before triggering, and returns it to false just after that (See code below). What disturbed me more is that I tried it without the flag and worked without problems. (Maybe it's because I'm not using a container, or because the plugin doesn't have anything about drawing enabled, or some other reason).

    I would like to know what can possibly go wrong if I create some instance and trigger OnCreated without setting that flag to true.

    SysActs.prototype.CreateObject = function (obj, layer, x, y) 
    {
    if (!layer || !obj)
    	return;
    
    var inst = this.runtime.createInstance(obj, layer, x, y);
    
    if (!inst)
    	return;
    
    this.runtime.isInOnDestroy++;
    
    var i, len, s;
    this.runtime.trigger(Object.getPrototypeOf(obj.plugin).cnds.OnCreated, inst);
    
    if (inst.is_contained)
    {
    	for (i = 0, len = inst.siblings.length; i < len; i++)
    	{
    		s = inst.siblings[i];
    		this.runtime.trigger(Object.getPrototypeOf(s.type.plugin).cnds.OnCreated, s);
    	}
    }
    
    this.runtime.isInOnDestroy--;
    
    [...]
    [/code:270emwgh]
  • You can do something quite similar by modifying the Function plugin, making it log each function call.

  • Use greater or equal on the condition

    PS.: Your object's speed depends on the fps, therefore, on the performance, use delta time to make it independent. (Look for 'Delta-time and framerate independence' at the manual)

  • Have you tried with the Sprite's "Pick Top/Bottom" condition ?

  • Not at the moment that I'm aware of. C2 doesn't have any capabilities to handle this that Im aware of. With that said, you could always do something fancy with git. have a single repository with your common used code and then fork it for each new project. From there you could pull from the main branch everytime you have a change. Just an idea.

    Just tried this.. made a directory common/ inside 'Event Sheet/'. At the .caproj file, referenced one (<event-sheet>common/Button.xml</event-sheet>), everything worked just fine. But when I saved the changes, C2 copied the Button.xml file to the 'Event Sheet' directory, and erased my reference line from the .caproj

  • I have a bunch of projects that behave similarly in many ways. At the moment, I copied the event sheets responsible for such behavior.

    It works, but in the future the behavior will change, and replicating those changes everywhere will be a pain in the ass. Is there some way to reuse the behavior and auto-replicate those changes to all my projects ?

  • I tricked you, because there are two suggestions in this post

    First, it would be nice to have the export route saved in the .capx/.caproj, so I dont need to search the same directory every time I have to export (many times a day).

    Secondly. Why in the world the group collapsed property is saved in the .xml (not the uistate)? It becomes really annoying seeing diffs where the only change is a collapsed="1"

  • I'm using the websocket plugin to communicate with a remote server. This plugin is nice, but somewhat "raw", so I've done a Communicator object (An invisible sprite with some function names as instance variables) that handles the websocket events easily, for my purposes.

    It works fine, but copying to a new project is annoying. I'm thinking of doing a plugin using the sdk, but it needs the websocket plugin (unless i copy all the code which don't seem to be a good idea). So, i would like the IDE to tell me that, in order to use my Communicator plugin, I need the websocket plugin included (Preferably with a clear message).

    Is it possible ?

  • Nevermind, find it out myself.. here's the explanation of the problem if someone is interested

    scirra.com/forum/r102-breaking-change-questions_topic56576_post352637.html

  • When you create the Gate object, its animation frame is unknown, i guess it is 0, but let's say that is unknown.. so, when you are asking for the animation frame, you are asking for the animation frame of an object with unknown variables.. have you tried it in this order?

    [Add score]

    Gate - Destroy

    Gate - Create

  • ok, i think i understood your question. Are you asking for something like having two objects on the edge of a circle and spin them continuosly? if the answer is yes..

    let's say o1.angle is always at 45 degrees from origin, and o2.angle always at 45 from o1. and let's do a somewhat generic pseudocode

    angle_offset : the angle of 'origin'

    angle_increment: spinning 'speed'

    a <- b : set a to b

    o.angle : the angle offset from the origin of the object

    const angle_increment = 1
    const o1.angle = 45
    const o2.angle = 90
    every tick:
         for each object o:
              o.x <- h * cos(o.angle + angle_offset) + c_x
              o.y <- h * sin(o.angle + angle_offset) + c_y
         angle_offset <- angle_offset + angle_increment
    

    Note: the angle_offset assignment is outside the for each loop.

    Edit: removed numbers from the executing code.. just remember, the less constants as numbers(1,2,3) and the more constants as variables (angle_increment) the happier you 'll be when adding modifications

  • Bearing in mind that the circle itself is rotating as (o1) rotates around it.

    btw, what do you mean with this ? something like the earth rotating around the sun while the moon rotates around the earth?

  • Yes.. again trigonometry

    tan definition:

    tan angle = opposite / adjacent

    atan is the inverse of tan, so

    angle = atan (opposite / adjacent)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok.. if you are interested on knowing more about this fun geometrical things, and have the time, take a look at the Euclid's Elements: en.bookfi.org/book/492577

  • Do you know pythagorean theorem? well, if you take a pythagorean triangle with a fixed hypotenuse, and a fixed origin point, and only draw the other point of the hypotenuse for every possible angle, you'll get a circle.

    Taking that on account.. your problem is easily solved, remembering trigonometry and that fun word 'sohcahtoa'

    h : hypotenuse, radio of your circle

    c_x,c_y : center of the circle

    a : angle of the circle

    sin definition:

    sin a = opposite / hypotenuse

    we can think of the opposite as the difference in y from the center, so we have

    sin a = y / h .. y = h * sin(a) , here i'm assumpting that the centre of the circle is 0.. i guess that isn't your case, so we just offset it

    y = h * sin (a) + c_y

    cos definition:

    cos a = adjacent / hypotenuse = x / h

    x = h * cos (a) + c_x

    so, here is your answer

    x = h * cos (a) + c_x

    y = h * sin (a) + c_y

    where

    h : hypotenuse, radio of your circle

    c_x,c_y : center of the circle

    a : angle of the circle

    x,y : your points