SAAj's Recent Forum Activity

  • I toyed around with the generator and decided that, for my purposes, it was indeed much easier to simply use 1 sprite and assign each rollable object its own animation and private variables. The application I'm trying to create is a 'challenge' screen for a racing RPG; the player and opponent randomly draw a vehicle each, followed by the player choosing the race type the vehicles should participate in. Each vehicle has 3 private variables denoting its proficiency in the race types, and there are 3 'subtract' buttons, one for each race type. These buttons are set to subtract 1 from their respective private variable from both the player and opponent; when one of the two reaches 0, that object is destroyed and the button is disabled, declaring the remaining vehicle the winner.

    Ideally, the player should open the application, roll the vehicles, and click on the desired race type repeatedly until one vehicle is destroyed. However, I'm running into an odd problem. I set the global variables 'RollPlayer' and 'RollOpponent' to Random(2), as well as assigning new animations to the Player and Opponent objects based on their respective global variables (0=Ford Fusion & its private variables, 1=Ford Flex & its private variables). For some reason, the subtract buttons usually don't work after I've rolled the vehicles. They work just fine beforehand (the default animation has all 3 private variables set to 2, so 2 clicks of any button will destroy both of them), but usually refuse to respond after the vehicles are rolled. I'm not sure if they're not subtracting, not destroying when they are equal to or less than zero, or something else altogether.

    I've got the private variables 'RollPlayer' and 'RollOpponent' set to -1 initially, and I tried assigning all the commands to key presses instead of buttons. I'm still getting the same problem. If it would help, I can upload the .cap file, though I've never really uploaded anything other than pictures/videos, and have no idea what services to use.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I assume that you know that actions directly after a create/spawn action will pick the newly created object. But I believe the problem here is that you're creating the object by name.

    If possible you should use just different frames (for static objects) instead of different sprites. Or if it needs to be animated, use different animations. That would make your life a whole lot easier. But might not be feasible depending on what your sprites need to be able to do.

    So in case you absolutely need to have different sprites, always remember what Ashley said back in 2009:

    [quote:1gw3vesw]The way it is, though, is that when you create an object, it doesn't really exist until the end of the next top level event or trigger. (A top level event is anything which is not a subevent of anything else - I can't remember if events in groups of events count)

    Always keep that in mind when you're trying to manipulate newly created objects.

    So in this case, if you have an object created by name and want to assign a certain PV to it, you could do it similar to this:

    http://dl.dropbox.com/u/2306601/Rollit.cap

    I'm making use of a family and a set the PV to be changed to a negative initial value to indicate that it hasn't been changed yet.

    What's also important is that you shouldn't use Button objects for creation events, since they're messing with the newly created object in a way that changes applied to it will appear one tick too late. That's the best I can explain it right now, there's a comment in the cap which should make it clearer.

    Also let me mention that there is a Python-method to safely pick newly created objects. But I'm not much of a Python-user and can't recall it right now. A forum search should come up with it or somebody else will be so kind to repost it here.

    Thanks for taking the time; I'm still trying to fully grasp it, but the .cap is very helpful, as is your explanation.

  • Disclaimer: I've searched the FAQ, tutorials, documentation, and this forum trying to find a solution to this problem, but I don't know exactly what to call it or where to look. I'm sure it's here, I'm just new to scripting/coding and thus unfamiliar with the jargon.

    The situation: I've got a 'roll' button that randomly generates a number between 1 and 20 when clicked. Each number corresponds to 1 of 20 sprites; when a sprite's number is rolled, it is generated. I've also got a 'test' button that subtracts from the generated sprite's private variables.

    My question: how do I get the 'test' button to subtract from the private variables of the generated sprite without it knowing in advance which sprite it will be? Do I create some sort of 'placeholder' sprite that mimics the private variables of the generated sprite, and tell the test button to always subtract from the placeholder? If not, how do I tell the test button which sprite to subtract from?

SAAj's avatar

SAAj

Member since 4 Dec, 2010

None one is following SAAj yet!

Trophy Case

  • 13-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

15/44
How to earn trophies