Coder Social home page Coder Social logo

arcade-text's Introduction

Text Sprite Build status badge

Usage

This extension allows you to create "text sprites" which are just sprites created with the visual appearance of text. All standard behavior and APIs for sprites apply to them. In addition, the Text Sprite extension has helpful blocks for working with and changing the appearance of text sprites.

Note that when unicode characters are in use, the font height used in text sprites will always be a multiple of 12px. Whereas otherwise we prefer to use multiples of height 8px or 5px fonts.

Screen Shot 2020-08-20 at 8 00 21 AM

Use this extension

This repository can be added as an extension in MakeCode.

  • open https://arcade.makecode.com/
  • click on New Project
  • click on Extensions under the gearwheel menu
  • search for the URL of this repository and import

Edit this extension

To edit this repository in MakeCode.

Blocks preview

This image shows the blocks code from the last commit in master. This image may take a few minutes to refresh.

A rendered view of the blocks

Supported targets

  • for PXT/arcade
  • for PXT/arcade (The metadata above is needed for package search.)

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

arcade-text's People

Contributors

darzu avatar jwunderl avatar microsoftopensource avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

aqeeaqee

arcade-text's Issues

TextSprites and their Images remain in memory after being destroyed

I have been working on a project that uses Kittenbot's Meowbit, which has 2MByte spi-flash memory, which is a bit tight for the requirements by my client.

I wish to cut down on the memory usage after hitting the dreaded 021 error. I have limited success by setting all sprites to GHOST (0.6% reduction due to hitboxes as per heap snapshot).

My best hope is to free the memory contributed by TextSprites along with their images after initial use at the title screen of my game (2884/23516 per Summary with heap snapshot) but they never get freed.

Project Link

The snapshots:

Threads:
Thread 1:
   at <main> (pxt_modules/arcade-text/main.ts:1:1)



Summary:
     12      1 ButtonHandler
     16      1 SprayFactory
     16      1 inline (pxt_modules/game/scene.ts:135:73)
     16      1 inline (pxt_modules/game/scene.ts:144:70)
     16      1 inline (pxt_modules/game/scene.ts:153:80)
     16      1 inline (pxt_modules/game/scene.ts:164:77)
     16      1 inline (pxt_modules/game/scene.ts:169:81)
     16      1 ButtonEventHandlerState
     20      1 Background
     20      1 inline (pxt_modules/game/controllerbutton.ts:266:45)
     24      1 ScreenEffect
     24      1 SpriteMap
     24      2 Melody
     28      1 ArcadePhysicsEngine
     32      1 AnyButton
     36      3 FastRandom
     40      2 ImageEffect
     44      1 EventContext
     44      1 Camera
     64      4 inline (pxt_modules/game/multiplayer.ts:50:13)
     64      4 inline (pxt_modules/game/multiplayer.ts:55:13)
     84      7 FrameCallback
     96      4 Controller
    104      1 Scene
    168      6 {...}
    180      9 EventHandler
    896     28 Button
   1256     28 [...]
   3372    114 TOTAL


Large Objects:
    408 [...] cachedSin
    408 [...] cachedCos
    104 Scene eventContexts.[0].frameCallbacks.[0].handler._cap0
     44 EventContext eventContexts.[0]
     44 [...] eventContexts.[0].handlers
     44 Camera eventContexts.[0].frameCallbacks.[0].handler._cap0.camera
     40 {...} font8
     40 {...} font12
     40 {...} font5
     36 [...] _players.[1].buttons
     36 [...] _players.[2].buttons
     36 [...] _players.[3].buttons
     36 [...] A._owner.buttons
     36 [...] eventContexts.[0].frameCallbacks
     32 Button A
     32 Button A._owner.buttons.[5]
     32 Button A._owner.buttons.[0]
     32 Button A._owner.buttons.[1]
     32 Button A._owner.buttons.[2]
     32 Button A._owner.buttons.[3]

New Objects:

sim.js:4401 Threads:
Thread 1:
   at <main> (pxt_modules/arcade-text/main.ts:1:1)

Thread 2:
   at pause (pxt_modules/base/pause.ts:8:1)
   at inline (pxt_modules/screen/frame.ts:18:27)

Thread 3:
   at pause (pxt_modules/base/pause.ts:8:1)
   at inline (pxt_modules/base/eventcontext.ts:114:35)



Summary:
      8      1 SpriteSet
     12      1 ButtonHandler
     16      1 SprayFactory
     16      1 inline (pxt_modules/game/scene.ts:135:73)
     16      1 inline (pxt_modules/game/scene.ts:144:70)
     16      1 inline (pxt_modules/game/scene.ts:153:80)
     16      1 inline (pxt_modules/game/scene.ts:164:77)
     16      1 inline (pxt_modules/game/scene.ts:169:81)
     16      1 ButtonEventHandlerState
     20      1 Background
     20      1 inline (pxt_modules/game/controllerbutton.ts:266:45)
     24      1 ScreenEffect
     24      1 SpriteMap
     24      2 Melody
     28      1 ArcadePhysicsEngine
     32      1 AnyButton
     36      3 FastRandom
     40      2 ImageEffect
     44      1 EventContext
     44      1 Camera
     64      4 inline (pxt_modules/game/multiplayer.ts:50:13)
     64      4 inline (pxt_modules/game/multiplayer.ts:55:13)
     84      7 FrameCallback
     96      4 Controller
    104      1 Scene
    112      4 Hitbox
    180      9 EventHandler
    192      6 {...}
    656      4 TextSprite
    896     28 Button
   1392     39 [...]
  11844      5 Image
  16152    139 TOTAL


Large Objects:
   9616 Image screen
    676 Image eventContexts.[0].frameCallbacks.[0].handler._cap0.physicsEngine.sprites.[1]._image
    604 Image eventContexts.[0].frameCallbacks.[0].handler._cap0.physicsEngine.sprites.[0]._image
    504 Image eventContexts.[0].frameCallbacks.[0].handler._cap0.physicsEngine.sprites.[3]._image
    444 Image eventContexts.[0].frameCallbacks.[0].handler._cap0.physicsEngine.sprites.[2]._image
    408 [...] cachedSin
    408 [...] cachedCos
    164 TextSprite eventContexts.[0].frameCallbacks.[0].handler._cap0.physicsEngine.sprites.[0]
    164 TextSprite eventContexts.[0].frameCallbacks.[0].handler._cap0.physicsEngine.sprites.[1]
    164 TextSprite eventContexts.[0].frameCallbacks.[0].handler._cap0.physicsEngine.sprites.[2]
    164 TextSprite eventContexts.[0].frameCallbacks.[0].handler._cap0.physicsEngine.sprites.[3]
    104 Scene eventContexts.[0].frameCallbacks.[0].handler._cap0
     44 EventContext eventContexts.[0]
     44 [...] eventContexts.[0].handlers
     44 Camera eventContexts.[0].frameCallbacks.[0].handler._cap0.camera
     40 {...} font8
     40 {...} font12
     40 {...} font5
     36 [...] _players.[1].buttons
     36 [...] _players.[2].buttons

New Objects:

sim.js:4401 Threads:
Thread 1:
   at <main> (pxt_modules/arcade-text/main.ts:1:1)

Thread 2:
   at pause (pxt_modules/base/pause.ts:8:1)
   at inline (pxt_modules/screen/frame.ts:18:27)

Thread 3:
   at pause (pxt_modules/base/pause.ts:8:1)
   at inline (pxt_modules/base/eventcontext.ts:114:35)



Summary:
      8      1 SpriteSet
     12      1 ButtonHandler
     16      1 SprayFactory
     16      1 inline (pxt_modules/game/scene.ts:135:73)
     16      1 inline (pxt_modules/game/scene.ts:144:70)
     16      1 inline (pxt_modules/game/scene.ts:153:80)
     16      1 inline (pxt_modules/game/scene.ts:164:77)
     16      1 inline (pxt_modules/game/scene.ts:169:81)
     16      1 ButtonEventHandlerState
     20      1 Background
     20      1 inline (pxt_modules/game/controllerbutton.ts:266:45)
     24      1 ScreenEffect
     24      1 SpriteMap
     24      2 Melody
     28      1 ArcadePhysicsEngine
     32      1 AnyButton
     36      3 FastRandom
     40      2 ImageEffect
     44      1 EventContext
     44      1 Camera
     64      4 inline (pxt_modules/game/multiplayer.ts:50:13)
     64      4 inline (pxt_modules/game/multiplayer.ts:55:13)
     84      7 FrameCallback
     96      4 Controller
    104      1 Scene
    112      4 Hitbox
    180      9 EventHandler
    192      6 {...}
    656      4 TextSprite
    896     28 Button
   1344     39 [...]
  11844      5 Image
  16104    139 TOTAL


Large Objects:
   9616 Image screen
    676 Image title_top2._image
    604 Image title_top1._image
    504 Image title_bottom._image
    444 Image title_by._image
    408 [...] cachedSin
    408 [...] cachedCos
    164 TextSprite title_top1
    164 TextSprite title_top2
    164 TextSprite title_by
    164 TextSprite title_bottom
    104 Scene eventContexts.[0].frameCallbacks.[0].handler._cap0
     44 EventContext eventContexts.[0]
     44 [...] eventContexts.[0].handlers
     44 Camera eventContexts.[0].frameCallbacks.[0].handler._cap0.camera
     40 {...} font8
     40 {...} font12
     40 {...} font5
     36 [...] _players.[1].buttons
     36 [...] _players.[2].buttons

New Objects:
   9616 Image screen
    676 Image title_top2._image
    604 Image title_top1._image
    504 Image title_bottom._image
    444 Image title_by._image
    164 TextSprite title_top1
    164 TextSprite title_top2
    164 TextSprite title_by
    164 TextSprite title_bottom
     28 Hitbox title_top1._hitbox
     28 Hitbox title_top2._hitbox
     28 Hitbox title_by._hitbox
     28 Hitbox title_bottom._hitbox
      8 [...] eventContexts.[0].frameCallbacks.[0].handler._cap0.overlapMap.-1
      8 [...] title_top1._overlappers
      8 [...] title_top1._obstacles
      8 SpriteSet eventContexts.[0].frameCallbacks.[0].handler._cap0.spritesByKind.1003
      8 [...] eventContexts.[0].frameCallbacks.[0].handler._cap0.spritesByKind.1003._sprites
      8 [...] eventContexts.[0].frameCallbacks.[0].handler._cap0.overlapMap.1003
      8 [...] title_top2._overlappers
      8 [...] title_top2._obstacles
      8 [...] title_by._overlappers
      8 [...] title_by._obstacles
      8 [...] title_bottom._overlappers
      8 [...] title_bottom._obstacles

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.