User Tag List

Results 1 to 7 of 7

Thread: Surface Object - Set Pixel

  1. #1
    No Products Registered

    Join Date
    Dec 2012
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Surface Object - Set Pixel

    Is there a way to test the position of a Surface Object by a pixel?

    example-1.png

    Theoretically if you could call a routine where the pixel of an active test object is overlapping a background object (both Surface Objects), then you could use Transparency>Alpha channel>Set pixel and change that pixel to transparent or opaque. The result I'm looking for is demonstrated in the attached picture - a test circle scrolling over a particular background could disappear pixel-by-pixel, giving the illusion of the circle sliding under the background, or even reappearing via sliding over a different background. There doesn't seem to be a way to do that though - all I have is the basic "is [object] colliding with/overlapping [another object]".

    Alternatively I could try running a Fastloop to cycle through every pixel of the active test object one after another, testing the position of that pixel against the boundaries of the background Surface Object - but that will barely suffice if there is one instance of the object on-screen, and will slow the engine down to a crawl if multiple instances are called for.

    Even when a background Surface Object is visibly broken up into chunks because of calls for rectangles filled in with Alpha=0, it will only call a collision when the active test object is overlapping an opaque part of that background - but you can't seem to glean any information from that to put into 'Set pixel'.

  2. #2
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The way I would do this is have two separate surfaces, one for each side, and then have actives that, when they overlap, you draw a circle at that location. It should seam up and look like that between the two surfaces.

  3. #3
    No Products Registered

    Join Date
    Dec 2012
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jacob View Post
    The way I would do this is have two separate surfaces, one for each side, and then have actives that, when they overlap, you draw a circle at that location. It should seam up and look like that between the two surfaces.
    When the test circle overlaps with the appropriate surface object, the surface object is redrawn and then a new circle is drawn on it. If the surface object were not redrawn, there would be a long line that looked like the circle was being dragged across it in a big smear.

    That seems to work well enough, the circles are a solid color and are drawn/not drawn on the appropriate surface objects. Unfortunately I'm now trying to adapt that system with more advanced videogame sprites and I'm not sure how to go about it.

    example2.png

    The "!" squares are the example sprites for this stage and the surface objects use actual background images rather than flat colors. When the darker example sprites overlap with the brighter surface, they need to be drawn on that surface, and vice versa - but in a way that doesn't destroy the already-existing background for each surface.

    EDIT: Ideally the example sprites should be any kind of sprite ranging from item box to spaceship, and the transparency of that sprite should be carried over to the background surface (in other words if the picture is drawn on the surface there won't be an ugly bounding box surrounding that picture).

  4. #4
    No Products Registered

    Join Date
    Dec 2012
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've gotten a bit closer.

    Both Surface Objects, the backgrounds, have two frames - Image 0 the editing frame, and Image 1 the pristine backup of Image 0.

    Code:
    ALWAYS >
    WhiteSurface - set blit destination position to (X WhiteSurface, Y WhiteSurface)
    Blit Image 1
    At the beginning of the loop the Surface Object is effectively wiped clean.

    Code:
    BlackItem is overlapping WhiteSurface>
    WhiteSurface - set blit destination position to (X BlackItem, Y BlackItem)
    Blit Image 0 of BlackItem
    This overlays the image of the Active Object onto the Surface Object.

    Only problem is, multiple instances of the same item don't seem to blit on the background. If an item is transitioning onto a background but another instance appears, that first instance disappears completely. I've never been good at handling multiple instances, so I'm not sure what to do here.

  5. #5
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Create an alterable value called ID for your actives. At start of frame (and whenever you create a new one) do Spread Value 0 in ID for Active. This will give each of your objects a unique number which which you can reference it. Then, you'll need to run a loop NObjects("Active") times called "Blit" and then do

    On Loop Blit
    +ID of Active = loopindex("Blit")
    --here is where you draw the object.

    Since you check the ID against the loop index, each object will be drawn individually and you should get them all.

  6. #6
    No Products Registered

    Join Date
    Dec 2012
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Jacob View Post
    Create an alterable value called ID for your actives. At start of frame (and whenever you create a new one) do Spread Value 0 in ID for Active. This will give each of your objects a unique number which which you can reference it. Then, you'll need to run a loop NObjects("Active") times called "Blit" and then do

    On Loop Blit
    +ID of Active = loopindex("Blit")
    --here is where you draw the object.

    Since you check the ID against the loop index, each object will be drawn individually and you should get them all.
    It works. It actually works. The relief I'm feeling right now is palpable.

    Jacob, if you don't mind, would you PM me your online handle or real name so I can credit you under Special Thanks?

  7. #7
    Clicker Multimedia Fusion 2SWF Export Module
    Jacob's Avatar
    Join Date
    Jul 2007
    Location
    Second pixel to the right
    Posts
    3,208
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's no need for that, but if you insist my online handle is Jacob "Jacob" Pariseau

Similar Threads

  1. Surface Object Help
    By Hydra in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 2nd February 2017, 01:42 PM
  2. Surface Object?
    By BartekB in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 1st July 2014, 02:06 PM
  3. How would you move an object in straight line pixel by pixel from location to another
    By Tsun in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 22nd December 2012, 10:38 PM
  4. Surface Object
    By harrysgames in forum iOS Export Module Version 2.0
    Replies: 3
    Last Post: 23rd February 2012, 02:37 PM
  5. Surface object
    By Looki in forum Released Extensions
    Replies: 4
    Last Post: 18th October 2010, 01:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •