Yann's Recent Forum Activity

  • You can't without a plugin.

    The closest you can achieve without you events getting too complex, is to use a sprite with a circular collision polygon and do something like

    // flatten the array
    -> Array: set size to (0,1,1)
    + myObject is overlapping circularDetector
    + foreach myObject
       -> Array: push myObject.UID in X axis

    Then you have the UID of all the object whose collision polygon overlap the circularDetector's one.

    The UID is the closest thing you'll have to a "reference" in c2's event sheet system.

    Also it's an unperfect solution since your circularDetector won't have a perfect circle has a collision polygon but a... polygon (by default an octogon)

    And it's inperfect because it's not really an AABB test but a collision polygon against collision polygon.

    But if you set the collision polygon of myObject to bounding box... you'll be closer to what you asked (:

  • fullscreen mode

  • container is the closest you can get

    though you won't be able to remove parts using the destroy action because container tightly tie the objects together so they can't live without each other.

    In other terms, if you destroy one object from a container, all the other object will be destroyed and if you create one, all the other will be created.

    So to achieve your effect I would advise to remove them by setting them to invisible.

    Anyway... containers

  • Your first and second method are equivalents since cloning means creating a new objecttype but based on the properties of the instance you cloned from instead of starting from default properties.

    So in the end we're down to using multiple instances or multiple objecttypes.

    First, I don't think there's any difference in terms of performance. The text plugin uses some cache system to avoid garbage collection, but this cache system is shared by all the objecttypes created from this plugin. So performance shouldn't be considered here.

    Now in term of project management, indeed, creating instances (copy) lower the number of object type to handle.

    The catch is when you want to manage them by event: if you use one objecttype by text, you don't have to worry about filtering them using conditions (picking).

    To me, that's not really a problem though.

    I try to use instances of one objecttype when this objecttype represents the same "conceptual" idea, and I just use instance variables to tell them appart.

    For instance, for a quizz game, I could have a "question" objecttype and an "answer" objecttype and put in the layout one instance of "question" and 4 instances of "answer", put an instance variable to tell which is which, and using events pick them one by one (in a loop) and then fill them during runtime.

    (and instance variable isn't that necessary here, you could use the IID)

    So my answer would be that there's no best way. Just pick the one that makes the most sens to you at the moment

  • You can use the default Browser plugin and do something like:

    System: Browser.ExecJS("window.innerWidth") < Browser.ExecJS("window.innerHeight")
        -> display your message
  • 3D games ARE possible in construct 2

    And indeed, you need to create a plugin.

    I tried, and I achieved result, however such plugin is a real pain to use because if you want to really work with C2's picking system, you need more than one plugin.

    Why? Because for 3D rendering you need many different abstract objects.

    You need objects like lights and meshes. You need what's called a scene graph to organize your objects in the scene (add and remove them). You need a camera object to control position and direction of view as well as field of view. You need a renderer object that allows you to connect a camera to a given scene graph.

    You also need materials and texture. (I'm mostly refering to how three.js works but I've seen such design in some software as well)

    And you can't really stick everything into one big fat plugin. Well... You can, but then you wouldn't be able to pick objects since everything would be handled by the plugin. You would also have to find a way to keep some references to instances to manipulate them in the event sheet...

    So a better solution would be to have a renderer plugin, a mesh plugin, material plugin, etc, this way you could pick materials and assign them to meshes, pick light and add or remove from scene graph, etc

    But that's a big work. And as some already said, you wouldn't even have anything showing up in the viewport of construct2.

    And also you would have to learn how the plugin suite work... which would be almost the same as to learn how three.js works (and 3D rendering in general... mipmapping, geometry instancing, model view matrices, etc...)

    And well... at some point... it would be like using a chainsaw to hammer a nail.

    Use the right tool for the job.

    I know c2's event system looks so easy that you feel this need to use it for 3D games, but remember, c2's event system is really just sugar coated programming. It wouldn't take that much effort to switch (for example) to unityscript (a bit more for unrealscript :D).

    If you already have a good level in C2, you've got good basics of programming. So after probably a month or two with unity, you'll be able to make what you want.

    And if you're good enough to create a 3D plugin for C2... Yeah... By all means, use unity :D

    for curious people, my 3D tests with C2 looks like that:

    Maze (use arrow keys)

    Just a rotating object

  • demo

    capx

  • structure.Timer.CurrentTime("03")
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • nemo

    Yeah, well, I actually wanted a virtual joystick that would appear where you first touch (:

    Kinda relative stick

    I indeed made another version with fixed buttons so I can just do a "on object touched" and capture the TouchID without having to check the touch.X value.

    But with a relative stick, I need first to check if it's on the left or right of the screen to know if it's the left or right stick.

  • jayderyu

    Ah yeah indeed

    I could have done

    Touch.XForID(Touch.TouchID)

    But still, I wonder why the Touch.TouchID and Touch.TouchIndex correspond to the last touch, but Touch.X is kinda forced to always be the first finger's position.

    To me, it would make more sense to put in the instanceProto.onPointerStart function

    this.trigger_x = touchx
    this.trigger_y = touchy

    And us those for the Exps.prototype.X and Exps.prototype.Y functions

  • Hi,

    Another suggestion (:

    Here is the situation: I had to implement some virtual joystick system for smartphones.

    The idea was to have two joysticks, a left one to move a character, and a right one to aim and shoot.

    And here is how it seemed natural to proceed:

    Global number rightID = -1
    Global number leftID = -1
    + on touch start
       + leftID = -1
       + Touch.X < scrollx
          -> set leftID to Touch.TouchID
       + rightID = -1
       + Touch.X >= scrollx
          -> set rightID to Touch.TouchID
    + on touch end
       + Touch.ID = leftID
          -> set leftID to -1
       + Touch.ID = rightID
          -> set rightID to -1

    Then I can track the position of the left and right finger

    The only issue is that the Touch.X expression (as well as the Touch.Y) will always give you the position of the first touch

    Here is the proof in the js code:

    Exps.prototype.X = function (ret, id, layerparam)
    {
       ....
       ret.set_float(layer.canvasToLayer(this.touches[0].x, this.touches[0].y, true));
       ...
    }

    The work around I used was to get the last touch using the touch index like this:

    + on touch start
       + leftID = -1
       + Touch.XAt(Touch.TouchCount-1) < scrollx
          -> set leftID to Touch.TouchID

    So my suggestion would be to:

    • either make Touch.X return the position associated with the trigger it's used in, and fall back to the first touch outside of a trigger context (that's already the case with TouchID and TouchIndex I believe)
    • or create a Touch.LastTouchX expression

    (I prefer the first solution (: )

  • Ashley

    alright thanks (:

Yann's avatar

Yann

Member since 31 Dec, 2010

Twitter
Yann has 5 followers

Connect with Yann