coloring sprites in a function - picking problem

0 favourites
  • 6 posts
From the Asset Store
Drawing game template ready to be published or customized
  • Hello, I am searching forums & FAQ & tutorials desperately for many days to solve my little beginner problem. It is my very first question in this forum & I hope I am not expressing myself too complicated:

    I�m creating sprites (circles) in an array (FOR EACH XY), assigning colors to them, then creating another sprite (the green corners) and calling a function to check, if the circle next to it is either blue or purple and making it the same color. The last part does not work obviously, the corners stay green and don�t turn blue or purple. The only corner picked & changing color is the on at the very bottom with the very first UID <img src="smileys/smiley18.gif" border="0" align="middle" />

    I added a textbox to prove if the 2 function parameters are passed correctly, which seems to be working. Apparently I havent understood when parameters get lost in new subevents or not passed to functions that are outside the loop or something else...

    I�m planning to add more conditions to check the surrounding circles for color and place the corner�s animation frame accordingly after I figured out the basic problem here. Can you help me please?

    corners staying green:

    <img src="" border="0" />

    <img src="" border="0" />

  • uhm I forgot the <img src="smileys/smiley9.gif" border="0" align="middle" />

  • You have a visibility problem, which in my opinion is the most illogical and annoying feature of Construct 2: objects created cannot be referenced(picked) before next top level event.

    In your case I'd reformat your code to use CornerSprite 'On created' rather than the function.

  • first of all thank you very much vee41 for your answer!

    yes, formerly I was doing the setanimationframe as you suggest right just after creating the corners directly in the FOReachXY but soon I realized that I need a function because the function as it is simplified here will be expanded to check for many many conditions from neighboring colors that I left out of this example. And I dont want to redo it like 15+ times.

    I read that a wait = 0 is used to have a fake event that triggers a next top level event? A function itself doesn?t seem to be a such an event, because it?s only triggered when called, right?

    Another thing makes me scratch my head, the distribution order UID indices for the corners seems to be vertically alligned in this example while the colors to the circles are being distributed horizontally following the array indices. These different index orders will be quite a complication when I will need to compare their values among each other. colorvalue of corner with UID and colorvalue of circle = array at x/y. damn!

    I?m very thankfull for any structuring hints :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes, wait 0 can be used to 'break up' events. Here is what I came up with, made few other changes to the project. Colors can be now set with single event, no matter how many you add. That should simplify things quite a bit.

    I wasn't really sure what your final intention on picking and choosing colors for corners is, so I just set the to pick the color of closest circle.

    Also notice how I used local variables 'blue' and 'purple' to keep things a bit cleaner. I never like to reference to a number inside code, rather into meaning of that number :)

    Colored corners

  • oh wow great stuff, there is lots of new things to lean from your version here, it so freaking CLEAN! great is also the idea with the identical & consistent animationframe numbers for circles & corners.

    what I want to achieve as final result is a map generator with

    smooth transitions for circles next to each other making them look connected.

    I had an older capx version of this where it "almost" worked but I need a more generic solution like yours:

    <img src="" border="0" />

    So my next endevour is to check what colors are the circles not only nearest but also above, below, next to each other etc. and then dependent on those conditions to assign colors to the particular corner. I�ll try :)

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